GNU bug report logs -
#73853
Should and-let* become a synonym for when-let*?
Previous Next
Full log
Message #67 received at 73853 <at> debbugs.gnu.org (full text, mbox):
Stefan Kangas <stefankangas <at> gmail.com> writes:
> Jim Porter <jporterbugs <at> 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.
This bug report was last modified 143 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.