bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#73853: 31.0.50; Should and-let* become a synonym for when-let*?


From: Stefan Monnier
Subject: bug#73853: 31.0.50; Should and-let* become a synonym for when-let*?
Date: Sun, 27 Oct 2024 10:41:13 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

> 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






reply via email to

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