[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Make regexp handling more regular
From: |
Stefan Monnier |
Subject: |
Re: Make regexp handling more regular |
Date: |
Thu, 03 Dec 2020 10:00:24 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
>>> 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
Re: Make regexp handling more regular, Daniel MartÃn, 2020/12/02
Re: Make regexp handling more regular, Juri Linkov, 2020/12/02
Re: Make regexp handling more regular, Adam Porter, 2020/12/02