emacs-devel
[Top][All Lists]
Advanced

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

Re: defvar without value


From: Bruno Félix Rezende Ribeiro
Subject: Re: defvar without value
Date: Fri, 10 Apr 2020 12:20:46 -0300

Hi Emanuel,

Emanuel Berg via "Emacs development discussions." <address@hidden>
writes:

> The supposedly parallel version isn't needed in my experience if there
> is `let*' [...] Maybe `let' will truly be parallel one day [...]

That’s not the only use of ‘let’, because it’s not a weaker form of
‘let*’ as one might first think.  Both are fundamentally different in
their operation and ‘let’ is indeed parallel in some strict theoretical
sense, in the same way ‘let*’ is sequential in the same sense.  Both
forms coincide in effect only in the trivial case: when there is no
reference to (textually) earlier variables being bound in the subsequent
forms being evaluated to obtain the values to be bound to the later
ones.

For instance consider the difference between

#+BEGIN_SRC elisp
  (let ((x 0))
    (let ((x (1- x))
          (y (1+ x)))
      (cons x y)))
#+END_SRC

and 

#+BEGIN_SRC elisp
  (let ((x 0))
    (let* ((x (1- x))
           (y (1+ x)))
      (cons x y)))
#+END_SRC

The former evaluates to ~(-1 . 1)~ while the latter to ~(-1 . 0)~.  Both
are valid expressions with sensible behavior and are not
interchangeable.  The answer to which one to use does *not* follow from
the criterion: “are the variables to be bound interdependent?”, since in
both cases they are (and the behavior is different).  The real question
to answer is: “should they be bound in sequence or in parallel?”


-- 
Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF]
<http://oitofelix.freeshell.org/>

Attachment: signature.asc
Description: PGP signature


reply via email to

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