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: Michael Heerdegen
Subject: bug#73853: 31.0.50; Should and-let* become a synonym for when-let*?
Date: Sun, 27 Oct 2024 10:16:00 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Stefan Kangas <stefankangas@gmail.com> writes:

> Jim Porter <jporterbugs@gmail.com> writes:
>
> > On the other hand, the way bindings work in 'if-let*' and 'when-let*'
> > are closer to 'let*' than 'let'. I think that's a false friend though,
> > since they're only similar, not actually the same (of course the
> > semantics couldn't be exactly the same or there'd be no reason for
> > 'if-let*' and 'when-let*' to exist).
>
> FWIW, this is the argument that convinced me that the `*`-versions are
> better: bindings are more like in `let` than in `let*`.  To my mind,
> that makes the `*`-naming more self-documenting and clear.

In the meantime I found out that I am not as decided as I thought:

I am actually using both versions in my own code.  Valid arguments for
either name exist - and it even depends on the case:

In this case I prefer the name without star:

#+begin_src emacs-lisp
(if-let ((a (does-an-a-exist?-then-return-it)))
    (use a)
  (do-something-else))
#+end_src

Here I prefer the name with star:

#+begin_src emacs-lisp
(and-let* ((a (an-a-exists))
           (b (b-depending-on-a-also-exists)))
  (test-using a b))
#+end_src

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.



Michael.





reply via email to

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