all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Emanuel Berg via "Emacs development discussions." <emacs-devel@gnu.org>
To: emacs-devel@gnu.org
Subject: Re: defvar without value
Date: Sat, 11 Apr 2020 01:07:02 +0200	[thread overview]
Message-ID: <878sj3kkix.fsf@ebih.ebihd> (raw)
In-Reply-To: 877dyngyep.fsf@oitofelix.com

Bruno Félix Rezende Ribeiro wrote:

>> 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.

OK, but then the trivial case is the sound one.
Reusing names in `let' bindings is like asking for
trouble. The only exception is when one temporarily
wants to have the old variable another value in another,
remote function. But then it should be super simple,
just assign the new value and invoke the function, and
snap back to normal.

> 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).

Well... IMO your example does not demonstrate one being
parallel and one being sequential as much as it is a way
of telling what x is refered to.

And there is a better way to do that, namely calling the
variables different things. And then:

(let ((x 0))
  (let ((a (1- x))
        (y (1+ a)) )
    (cons a y) )) ; DNC

But:

(let*((x 0)
      (a (1- x))
      (y (1+ x)) )
  (cons a y) ) ; (-1 . 1)

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




  reply	other threads:[~2020-04-10 23:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-01  0:03 defvar without value Michael Heerdegen
2020-04-01  0:36 ` Drew Adams
2020-04-01  0:59 ` Stefan Monnier
2020-04-01 22:45   ` Michael Heerdegen
2020-04-02  2:37     ` Stefan Monnier
2020-04-09  1:52       ` Michael Heerdegen
2020-04-09  2:04         ` Emanuel Berg via Emacs development discussions.
2020-04-09  2:20         ` Stefan Monnier
2020-04-09 23:34           ` Emanuel Berg via Emacs development discussions.
2020-04-10 15:20             ` Bruno Félix Rezende Ribeiro
2020-04-10 23:07               ` Emanuel Berg via Emacs development discussions. [this message]
2020-04-10 21:57           ` Michael Heerdegen
2020-04-01  1:21 ` Noam Postavsky
2020-04-01  1:53   ` Michael Heerdegen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878sj3kkix.fsf@ebih.ebihd \
    --to=emacs-devel@gnu.org \
    --cc=moasenwood@zoho.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.