emacs-devel
[Top][All Lists]
Advanced

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

Re: Replace trivial pcase occurrences in the Emacs sources


From: Stefan Monnier
Subject: Re: Replace trivial pcase occurrences in the Emacs sources
Date: Tue, 30 Oct 2018 23:09:15 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

>> LGTM, thanks.  We could maybe give a hint about why, e.g. saying that
>> there are no guarantees about the order and number of times they are run.
> Are these the only restrictions?

I think so, yes.

> Are there even cases where side effects can still be relied on -
> e.g. in
>
> #+begin_src emacs-lisp
> (pcase EXPR
>   ((and P1 (guard (prog1 t (setq x 15))) P2) BODY1)
>   ...)
> #+end_src
>
> is it legitimate to assume that x has been set to 15 if BODY1 is
> evaluated (and P1 and P2 don't touch x)?

Yes: pcase doesn't look inside the `guard`s so in order to get to BODY1
it had to evaluate `(prog1 t (setq x 15))` at some point.

But some of the preds and guards of other branches (both before and
after the one of BODY1) may also be run before getting to BODY1.


        Stefan



reply via email to

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