From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: `aset` on strings, changing the size in bytes Date: Sat, 08 Sep 2018 14:03:10 -0400 Message-ID: References: <88must56x4.fsf@gnu.org> <83efe4trsa.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1536430314 6493 195.159.176.226 (8 Sep 2018 18:11:54 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 8 Sep 2018 18:11:54 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Sep 08 20:11:50 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fyhi0-0001aB-RR for ged-emacs-devel@m.gmane.org; Sat, 08 Sep 2018 20:11:48 +0200 Original-Received: from localhost ([::1]:44028 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fyhk7-00089r-9n for ged-emacs-devel@m.gmane.org; Sat, 08 Sep 2018 14:13:59 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45470) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fyhj0-0007Dz-Ct for emacs-devel@gnu.org; Sat, 08 Sep 2018 14:12:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fyhZp-00054O-Mf for emacs-devel@gnu.org; Sat, 08 Sep 2018 14:03:27 -0400 Original-Received: from [195.159.176.226] (port=54733 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fyhZn-000500-R8 for emacs-devel@gnu.org; Sat, 08 Sep 2018 14:03:21 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1fyhXe-0007ur-32 for emacs-devel@gnu.org; Sat, 08 Sep 2018 20:01:06 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 37 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:8pa5JCDS5T0pfrWUD+LipXlZGxM= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:229507 Archived-At: > What's the justification for such an incompatible change, though? > This feature _is_ used, e.g. see ruler-mode.el. Indeed, ruler-mode is the main user I know of this feature. > I understand that the effect of the change will be that whenever one > wants to mutate a string by replacing a character, they would need to > cons a new string, with the likes of > > (setq str (concat (substring str ...) new-char (substring str ...))) > > is that right? There are several alternatives. The ones I'm familiar with are: - the `concat` option you mention - use a unibyte string - use a vector rather than a string - use a (temp)buffer rather than a string For ruler-mode, I've found the temp-buffer to be the better option. > Which means in practice that 'aset' will need to generally disappear > from string-processing code, because in practice it is impossible to > know when the byte length will change without complicated > calculations, so robust code will need to drop use of 'aset' for > strings, except in a small set of specialized situations. In the general case, indeed. But in my experience, `aset` is used very rarely on strings and many of those cases are known to only involve ASCII chars or to work on unibyte strings. > Or maybe the proposal is to modify 'aset' to do the above under the > hood? No, "'aset' do the above under the hood?" is what we have now. Stefan