From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Subject: Re: `aset` on strings, changing the size in bytes
Date: Sat, 08 Sep 2018 14:03:10 -0400 [thread overview]
Message-ID: <jwvy3cboosf.fsf-monnier+gmane.emacs.devel@gnu.org> (raw)
In-Reply-To: 83efe4trsa.fsf@gnu.org
> 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
next prev parent reply other threads:[~2018-09-08 18:03 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-07 19:52 `aset` on strings, changing the size in bytes Stefan Monnier
2018-09-07 21:33 ` Johan Bockgård
2018-09-07 23:12 ` Paul Eggert
2018-09-07 23:41 ` John Wiegley
2018-09-08 5:17 ` Richard Stallman
2018-09-08 6:34 ` Eli Zaretskii
2018-09-08 2:04 ` Stefan Monnier
2018-09-08 2:17 ` Paul Eggert
2018-09-08 6:41 ` Eli Zaretskii
2018-09-08 18:03 ` Stefan Monnier [this message]
2018-09-08 18:20 ` Eli Zaretskii
2018-09-08 18:36 ` Stefan Monnier
2018-09-08 20:59 ` Eli Zaretskii
2018-09-08 22:09 ` Stefan Monnier
2018-09-09 5:22 ` Eli Zaretskii
2018-09-10 0:18 ` Stefan Monnier
2018-09-09 6:07 ` Richard Stallman
2018-09-09 6:26 ` Eli Zaretskii
2018-09-09 14:44 ` Noam Postavsky
2018-09-09 15:17 ` Eli Zaretskii
2018-09-09 16:27 ` Noam Postavsky
2018-09-10 5:48 ` Richard Stallman
2018-09-10 3:03 ` Stefan Monnier
2018-10-16 21:05 ` Stefan Monnier
2018-09-10 5:47 ` Richard Stallman
2018-09-10 5:48 ` Richard Stallman
2018-09-10 3:02 ` Stefan Monnier
2018-09-08 6:03 ` Helmut Eller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvy3cboosf.fsf-monnier+gmane.emacs.devel@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).