[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: `aset` on strings, changing the size in bytes
From: |
Noam Postavsky |
Subject: |
Re: `aset` on strings, changing the size in bytes |
Date: |
Sun, 9 Sep 2018 12:27:21 -0400 |
On 9 September 2018 at 11:17, Eli Zaretskii <address@hidden> wrote:
> I meant to make aset cons a new string when it turns out the original
> one's data is too small to include the new contents.
>
>> the semantics of aset is to modify the original string, changing
>> that would surely break code that worked for decades.
>
> But if we are going to tell people aset won't work in those cases,
> that code will be broken as well, no?
Ah, I think I see the disconnect. You mean aset should return a new
string only in the case where the string needs to be resized (rather
than signalling an error), but otherwise continue to modify the string
in-place and return NEWELT as normal.
A conditional return value like that seems too awkward to be useful,
IMO. Instead of
(setq s (sset s idx newchar)) ; as in [1]
You would need:
(let ((new-s (aset s idx newchar)))
(when (stringp new-s)
(setq s new-s)))
In practice, I suspect people wouldn't bother a lot of the time, so in
the rare case where a string is resized there will just be confusingly
wrong answer instead of a clear error.
[1]: https://lists.gnu.org/archive/html/emacs-devel/2018-09/msg00387.html
- Re: `aset` on strings, changing the size in bytes, (continued)
- Re: `aset` on strings, changing the size in bytes, Eli Zaretskii, 2018/09/08
- Re: `aset` on strings, changing the size in bytes, Stefan Monnier, 2018/09/08
- Re: `aset` on strings, changing the size in bytes, Eli Zaretskii, 2018/09/08
- Re: `aset` on strings, changing the size in bytes, Stefan Monnier, 2018/09/08
- Re: `aset` on strings, changing the size in bytes, Eli Zaretskii, 2018/09/09
- Re: `aset` on strings, changing the size in bytes, Stefan Monnier, 2018/09/09
- Re: `aset` on strings, changing the size in bytes, Richard Stallman, 2018/09/09
- Re: `aset` on strings, changing the size in bytes, Eli Zaretskii, 2018/09/09
- Re: `aset` on strings, changing the size in bytes, Noam Postavsky, 2018/09/09
- Re: `aset` on strings, changing the size in bytes, Eli Zaretskii, 2018/09/09
- Re: `aset` on strings, changing the size in bytes,
Noam Postavsky <=
- Re: `aset` on strings, changing the size in bytes, Richard Stallman, 2018/09/10
- Re: `aset` on strings, changing the size in bytes, Stefan Monnier, 2018/09/09
- Re: `aset` on strings, changing the size in bytes, Richard Stallman, 2018/09/10
- Re: `aset` on strings, changing the size in bytes, Richard Stallman, 2018/09/10
- Re: `aset` on strings, changing the size in bytes, Stefan Monnier, 2018/09/09
Re: `aset` on strings, changing the size in bytes, Helmut Eller, 2018/09/08