From: Noam Postavsky <npostavs@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Emacs developers <emacs-devel@gnu.org>,
Richard Stallman <rms@gnu.org>,
Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Re: `aset` on strings, changing the size in bytes
Date: Sun, 9 Sep 2018 12:27:21 -0400 [thread overview]
Message-ID: <CAM-tV-_e=uXLSZs1mZvr0q5nM8QemDWuOSG+v1BMS9+wZbX=jw@mail.gmail.com> (raw)
In-Reply-To: <83d0tmr97o.fsf@gnu.org>
On 9 September 2018 at 11:17, Eli Zaretskii <eliz@gnu.org> 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
next prev parent reply other threads:[~2018-09-09 16:27 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
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 [this message]
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='CAM-tV-_e=uXLSZs1mZvr0q5nM8QemDWuOSG+v1BMS9+wZbX=jw@mail.gmail.com' \
--to=npostavs@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=rms@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).