[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: master baf331e 3/3: Rename replace-in-string to string-replace
From: |
Robert Pluim |
Subject: |
Re: master baf331e 3/3: Rename replace-in-string to string-replace |
Date: |
Mon, 28 Sep 2020 17:42:38 +0200 |
>>>>> On Mon, 28 Sep 2020 08:21:03 -0700 (PDT), Drew Adams
>>>>> <drew.adams@oracle.com> said:
Drew> FWIW - two things to say here, one about the name
Drew> `string-replace' and one, more general, about naming.
Drew> 1. `replace-in-string' is pretty self-explanatory,
Drew> certainly more so than `string-replace'. The latter
Drew> makes you think that you're replacing one string with
Drew> another (which you are) - but where? In a buffer? file?
Drew> the region?
Drew> `string-replace' suggests the same that `replace-string'
Drew> suggests. And we already have `replace-string':
Drew> "Replace occurrences of FROM-STRING with TO-STRING."
Drew> Now we'll have `replace-string' and `string-replace'?
Drew> Is that progress?
Drew> IIUC, `replace-in-string' was rejected because of some
Drew> incompatibility with XEmacs (name clash?). If so,
Drew> that's too bad, as replacing something within a string
Drew> is pretty clear from that name. And as the something
Drew> isn't part in the name, it's pretty straightforward to
Drew> guess that it's a substring that's being replaced.
Yes, itʼs an unfortunate clash. Then again, how much XEmacs code still
exists that depends on it?
Drew> Both `replace-in-string' and `replace-regexp-in-string'
Drew> are pretty clear. `string-replace' and
Drew> `string-replace-regexp' not so much.
I agree with this. However it seems some people are used to
<datatype>-<operation> type naming, hence the long discussion about
prefixing functions. (I use helm, which doesnʼt care what order the
subwords are in, presumably ivy/company etc donʼt either).
Drew> Just sayin'. I don't really have a great alternative
Drew> here. (`replace-substring'? `replace-within-string'?
Drew> `replace-some-of-string'? `replace-string-substring'?)
Drew> If `replace-in-string' is off limits for some reason
Drew> then so be it - but too bad.
I can offer: 'replace-string-in-string', which has the advantage of
being very regular with regard to 'replace-regexp-in-string' (and with
completion should not be very difficult to type).
Robert
--
Re: master baf331e 3/3: Rename replace-in-string to string-replace, Stefan Monnier, 2020/09/28
Re: master baf331e 3/3: Rename replace-in-string to string-replace, Stefan Kangas, 2020/09/28