help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Why looking-at-p works?


From: Marcin Borkowski
Subject: Re: Why looking-at-p works?
Date: Tue, 06 Mar 2018 21:42:13 +0100
User-agent: mu4e 1.1.0; emacs 27.0.50

On 2018-03-06, at 19:53, John Mastro <john.b.mastro@gmail.com> wrote:

> Marcin Borkowski <mbork@mbork.pl> wrote:
>> Hi all,
>>
>> (defsubst looking-at-p (regexp)
>>   "\
>> Same as `looking-at' except this function does not change the match data."
>>   (let ((inhibit-changing-match-data t))
>>     (looking-at regexp)))
>>
>> What happens is that if I make looking-at in the above code fail (e.g.,
>> by saying (looking-at-p 123)), inhibit-changing-match-data remains nil,
>> even though there is no unwind-protect here.  Why does it work like
>> this?
>
> If I understand your question correctly, it's nothing specific to
> looking-at-p. Let-bindings are protected by a sort of implicit
> unwind-protect so that they're always "un-done" upon exiting the scope,
> even in case of non-local exits like an error. Otherwise errors could
> leave global variables in unpredictable states.

Thanks, I suspected something like that.

Where is it documented?  I could find it neither in the Elisp Reference
nor in let's docstring.

TIA,

-- 
Marcin Borkowski
http://mbork.pl



reply via email to

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