[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Why looking-at-p works?
From: |
John Mastro |
Subject: |
Re: Why looking-at-p works? |
Date: |
Tue, 6 Mar 2018 10:53:15 -0800 |
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.
John