From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: emacs-devel@gnu.org, Juri Linkov <juri@linkov.net>
Subject: Re: Make regexp handling more regular
Date: Thu, 03 Dec 2020 10:00:24 -0500 [thread overview]
Message-ID: <jwvsg8nj61j.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87360nz3gl.fsf@gnus.org> (Lars Ingebrigtsen's message of "Thu, 03 Dec 2020 09:41:30 +0100")
>>> So my idle shower thought for the day is: Is there any reasonable path
>>> forward that the Emacs Lisp language could take here?
>> Currently the match data is like a dynamically bound variable accessible
>> to the callee. But maybe the match data should be only lexically-bound?
>> (This is just a vague idea, I don't know how to implement this.)
> Yes, I wondered whether one could use some lexical magic here, but I
> didn't quite see what that would look like.
Actually, currently the match-data is *not* like a dynamically-scoped
var, but like a global var. And we don't really need it to be lexically
scoped, we would be already well-served with a dynamically-scoped var.
E.g. we could have
(with-re-match "regexp"
...
(match-beginning 0)
...)
where `with-re-match` could look like
`(if re-match-data-in-use
(save-match-data
,@body)
(let ((re-match-data-in-use t))
,@body))
so we'd save the match-data lazily. [ Tho, it would still save the
match data more often than we currently do, of course. ]
Stefan
next prev parent reply other threads:[~2020-12-03 15:00 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-02 9:05 Make regexp handling more regular Lars Ingebrigtsen
2020-12-02 10:44 ` Lars Ingebrigtsen
2020-12-02 11:12 ` Stefan Kangas
2020-12-02 11:21 ` Philipp Stephani
2020-12-03 8:31 ` Lars Ingebrigtsen
2020-12-02 17:17 ` Stefan Monnier
2020-12-02 17:45 ` Yuan Fu
2020-12-02 19:24 ` Stefan Monnier
2020-12-03 8:40 ` Lars Ingebrigtsen
2020-12-03 8:38 ` Lars Ingebrigtsen
2020-12-03 15:10 ` Stefan Monnier
2020-12-03 16:58 ` Lars Ingebrigtsen
2020-12-03 17:40 ` Stefan Monnier
2020-12-02 21:19 ` Juri Linkov
2020-12-03 8:41 ` Lars Ingebrigtsen
2020-12-03 15:00 ` Stefan Monnier [this message]
2020-12-03 21:02 ` Juri Linkov
2020-12-03 22:20 ` Vasilij Schneidermann
2020-12-02 21:28 ` Daniel Martín
2020-12-03 4:16 ` Adam Porter
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=jwvsg8nj61j.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=juri@linkov.net \
--cc=larsi@gnus.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).