GNU bug report logs - #73853
Should and-let* become a synonym for when-let*?

Previous Next

Package: emacs;

Reported by: Stefan Monnier <monnier <at> iro.umontreal.ca>

Date: Thu, 17 Oct 2024 16:31:02 UTC

Severity: wishlist

Found in version 31.0.50

Full log


Message #106 received at 73853 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 73853 <at> debbugs.gnu.org, Jim Porter <jporterbugs <at> gmail.com>,
 Stefan Kangas <stefankangas <at> gmail.com>,
 Sean Whitton <spwhitton <at> spwhitton.name>
Subject: Re: bug#73853: 31.0.50; Should and-let* become a synonym for
 when-let*?
Date: Sun, 27 Oct 2024 10:41:13 -0400
> Thinking the first example further we could introduce parallel versions
> and name them `if-let', `when-let' and `and-let'.  They would be really
> analogue to `let' with respect to binding list semantics - compared to
> the non-parallel counterparts `if-let*' that are what we have now.
>
> ATM this idea looks appealing to me as a final goal.

The only natural semantics for something like when-let is the
"sequential" bindings of `let*`.  The `let` and `letrec` semantics are
"unnatural" here, so we should have only the `let*` semantics.

The implementation of a `when-let` that has a binding semantics like
that of `let` rather than `let*` would have to macroexpand

    (when-let ((a (fooa))
               (b (foob))
               ...)
      (bar))

to something like:

    (when-let* ((t1 (fooa))
                (t2 (foob))
                ...)
      (let ((a t1)
            (b t2)
            ...)
        (bar)))

So coders who "simplify" `when-let*` to `when-let` when the * version is
not needed, would in reality just pessimize their code.

I'll let you guess where I stand w.r.t to naming of `when-let` vs
`when-let*`, based on the fact that I originally implemented `dlet` with
the semantics of `let*`.  🙂


        Stefan





This bug report was last modified 140 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.