emacs-devel
[Top][All Lists]
Advanced

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

Re: Saving match data


From: Stefan Monnier
Subject: Re: Saving match data
Date: Wed, 28 Sep 2016 12:11:00 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

> I think this statement is surprising

Agreed.  That's why we have to write it explicitly in the doc ;-)

> and puts unnecessary burden on Elisp programmers.

Experience shows that it's the more efficient choice, tho: both in terms
of CPU efficiency and in terms of programmer efficiency.

So, yes, I think it's definitely necessary.

> Taken literally, Elisp programmers need to surround even calls to
> `car' with `save-match-data' because the documentation of `car'
> doesn't specify that it doesn't change the match data.

Indeed, there's also an expectation that "primitives" don't touch the
match-data.  It would be good to document it, tho it will take some work
to clarify what is meant by "primitive".

> "Notice that no functions are allowed to overwrite the match data unless
> they're explicitly documented to do so."

> and then clean up existing documentation and add `save-match-data' where
> appropriate.

That would imply adding save-match-data *everywhere*.  It's an enormous
amount of work, can't be automated, and comes with only two obvious results:
- our Elisp source code will be significantly larger.
- Emacs will be slower.


        Stefan




reply via email to

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