From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Eli Zaretskii <eliz@gnu.org>
Cc: "Mattias Engdegård" <mattiase@acm.org>,
ture@turepalsson.se, 41445@debbugs.gnu.org
Subject: bug#41445: 26.3; Query-replace triggers "match data clobbered by..."
Date: Sat, 23 May 2020 09:36:03 -0400 [thread overview]
Message-ID: <jwva71yls1p.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <83tv06zvgl.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 23 May 2020 15:28:42 +0300")
>> > The advantage of not doing this unconditionally is that we don't
>> > unnecessarily punishing callers that don't need match-data to be
>> > saved.
>>
>> For callers of the ucs-normalize- functions, correctness should come
>> first; their names, semantics or descriptions do not lead the user to
>> suspect them of clobbering the match data. It is an implementation leakage
>> which can be quite unexpected, as is witnessed by this bug.
>
> I thought we had some advice to Lisp programs not to assume that
> match-data will be preserved, but maybe I'm misremembering. Stefan,
> do you remember something along these lines?
Right, we follow a convention where, by default, any function can
clobber the match-data, with just some exceptions (typically,
small/trivial functions).
From that point of view, I see no reason why ucs-normalize-* should be
careful to preserve the match data.
This said, *if* it is the case that many/most calls to a given function
need to preserve the match-data around calls to it, it's of course
OK to simply move the match-data-saving into that function, especially
if that function's work dwarfs that of save-match-data.
I just added the following to `save-match-data`'s docstring, to try and
clarify:
NOTE: The convention in Elisp is that any function, except for a few
exceptions like car/assoc/+/goto-char, can clobber the match data,
so `save-match-data' should normally be used to save *your* match
data rather than your caller's match data.
-- Stefan
next prev parent reply other threads:[~2020-05-23 13:36 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-22 5:07 bug#41445: 26.3; Query-replace triggers "match data clobbered by..." Ture Pålsson
2020-05-22 10:46 ` Mattias Engdegård
2020-05-22 11:11 ` Eli Zaretskii
2020-05-22 11:16 ` Mattias Engdegård
2020-05-22 12:07 ` Eli Zaretskii
2020-05-22 12:21 ` Mattias Engdegård
2020-05-22 12:35 ` Eli Zaretskii
2020-05-23 11:36 ` Mattias Engdegård
2020-05-23 12:28 ` Eli Zaretskii
2020-05-23 12:37 ` Philipp Stephani
2020-05-23 13:07 ` Eli Zaretskii
2020-05-23 13:08 ` Mattias Engdegård
2020-05-23 13:36 ` Stefan Monnier [this message]
2020-05-23 15:43 ` Drew Adams
2020-05-27 14:31 ` Mattias Engdegård
2020-05-27 15:54 ` Eli Zaretskii
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=jwva71yls1p.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=41445@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=mattiase@acm.org \
--cc=ture@turepalsson.se \
/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).