emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: `aset` on strings, changing the size in bytes


From: Eli Zaretskii
Subject: Re: `aset` on strings, changing the size in bytes
Date: Sun, 09 Sep 2018 09:26:07 +0300

> From: Richard Stallman <address@hidden>
> Cc: address@hidden, address@hidden
> Date: Sun, 09 Sep 2018 02:07:15 -0400
> 
>   > But if I'm mistaken, and the current implementation does cons a new
>   > string, then what is your problem with it?  The original string is not
>   > mutable, it's just replaced wit ha new one.
> 
> "Replaced with the new one" requires relocatable strings.

Not necessarily, not in the example I've shown:

  (setq str (do-something-with str))

> But suppose we made a function like aset which returned
> the string.  That way, it could return a new string when necessary.
> It would be used like
> 
>    (setq s (sset s idx newchar))
> 
> Or we could define it to replace a substring:
> 
>    (setq s (srep s from to newsubstring))

Why not have aset do this under the hood?  Then we won't need to ask
people to change code that worked for decades.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]