From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.devel Subject: RE: master baf331e 3/3: Rename replace-in-string to string-replace Date: Mon, 28 Sep 2020 08:21:03 -0700 (PDT) Message-ID: <9e0ee248-a276-4f6a-a29f-a8984a0cf6fa@default> References: <20200926222500.20662.9159@vcs0.savannah.gnu.org> <20200926222503.227F720441@vcs0.savannah.gnu.org> <87h7riw3ti.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4028"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Robert Pluim , Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Sep 28 17:24:40 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kMv16-0000vJ-Hf for ged-emacs-devel@m.gmane-mx.org; Mon, 28 Sep 2020 17:24:40 +0200 Original-Received: from localhost ([::1]:45174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kMv15-0004Xm-JS for ged-emacs-devel@m.gmane-mx.org; Mon, 28 Sep 2020 11:24:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45440) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kMuxs-0000t4-6P for emacs-devel@gnu.org; Mon, 28 Sep 2020 11:21:20 -0400 Original-Received: from aserp2130.oracle.com ([141.146.126.79]:48078) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kMuxp-0004tU-Um for emacs-devel@gnu.org; Mon, 28 Sep 2020 11:21:19 -0400 Original-Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 08SFA23e003217; Mon, 28 Sep 2020 15:21:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : cc : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=DRd31BOMIQTq188oAXRbOZ0PECLg+/UKVD3LGli9avg=; b=wImpELa6Tg0YDHLx62lNcPCnPnGGiRmIUCFZEsszEu0uwKebfKXSyii7oRBWL0RAldSS UBbuv357dsAcpBJLbDKdXE7GComewzbOnudXRKSFdAgfe/usRuwQKw2N3Od4ckef1QmA j0q9PgXjrJQE1jNZsxsAiBKy1yrwczUWB3EOyb10B5i/pXVmFyhk9nVaPLccwM5YZQlw rOcNj4y9txaQYci02E/66zeXdwTzmAgWnPCDj4Pw81WV2qNpTybIjvd4xEC/U3MlcTVe sLHXkJi7b9Q9OkzlH+RbHjJ3OeQFhN9ptexyHMOUKJH19ywkKwvS6wNxZ0MyD130wz79 IQ== Original-Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 33su5answs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 28 Sep 2020 15:21:15 +0000 Original-Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 08SFAOM4097582; Mon, 28 Sep 2020 15:21:14 GMT Original-Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 33tfhwdj5c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 28 Sep 2020 15:21:14 +0000 Original-Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 08SFLE8W011288; Mon, 28 Sep 2020 15:21:14 GMT In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.5056.0 (x86)] X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9758 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 malwarescore=0 adultscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009280119 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9758 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 mlxscore=0 impostorscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009280119 Received-SPF: pass client-ip=141.146.126.79; envelope-from=drew.adams@oracle.com; helo=aserp2130.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/28 11:21:16 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.687, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:256603 Archived-At: > >> Do we need a (defalias 'string-replace-regexp > >> 'replace-regexp-in-string)? >=20 > Lars> I'm not very enthusiastic about adding noun-verb aliases for the > Lars> verb-noun functions we already have. It makes reading code more > Lars> confusing when we have several names for the same thing. >=20 > I agree, but in this case anyone who finds 'string-replace' is going > to have a harder time finding 'replace-regexp-in-string'. The two > functions are twins, they should be easy to find from one another. >=20 > Lars> Discoverability is an issue, though, and I'm working on that. >=20 > We can always stick cross-references in the respective docstring, but > people are still going to wonder about the irregular naming. FWIW - two things to say here, one about the name `string-replace' and one, more general, about naming. 1. `replace-in-string' is pretty self-explanatory, certainly more so than `string-replace'. The latter makes you think that you're replacing one string with another (which you are) - but where? In a buffer? file? the region? `string-replace' suggests the same that `replace-string' suggests. And we already have `replace-string': "Replace occurrences of FROM-STRING with TO-STRING." Now we'll have `replace-string' and `string-replace'? Is that progress? IIUC, `replace-in-string' was rejected because of some incompatibility with XEmacs (name clash?). If so, that's too bad, as replacing something within a string is pretty clear from that name. And as the something isn't part in the name, it's pretty straightforward to guess that it's a substring that's being replaced. Both `replace-in-string' and `replace-regexp-in-string' are pretty clear. `string-replace' and `string-replace-regexp' not so much. Just sayin'. I don't really have a great alternative here. (`replace-substring'? `replace-within-string'? `replace-some-of-string'? `replace-string-substring'?) If `replace-in-string' is off limits for some reason then so be it - but too bad. 2. Discoverability is important, yes - very important. But it's a mistake, IMO, to sacrifice more easily understood names in favor of less easily understood names, only because of easier discoverability by _prefix completion_. (Again, general argument here - not about `string-replace'.) Better to improve completion (use substring or regexp or fuzzy or ... completion) so that the better names are more easily discovered using completion. _Apropos_ should be our guide for discoverability, not prefix completion. Our UI (especially completion) should make it easy to discover a name by its "components", in whatever order they might appear. [I have a lot of experience with "apropos" completion, including ways to match name components/substrings in arbitrary order. That's lacking in vanilla Emacs.] We should not name things with discovery by prefix completion foremost in mind. That's a step backward. If all other things are equal (rare), prefix-oriented discovery can be nice to have - nothing more. This point (#2) is not about _what can make_ a name more understandable. (There are lots of things to consider for that.)=20 And this point isn't an argument favoring noun-verb or verb-noun. This is only to favor understandable names (however that's judged), and to deal with discoverability separately, rather than elevating prefix-completion discoverability as an important criterion for naming. And this point says nothing about the value of naming _consistency_. That's a different, but related, topic.