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


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: 73853 <at> debbugs.gnu.org
Cc: monnier <at> iro.umontreal.ca
Subject: bug#73853: 31.0.50; and-let* is useless
Date: Thu, 17 Oct 2024 12:27:39 -0400
Package: Emacs
Version: 31.0.50


According to its docstring, `and-let*` does:

    Bind variables according to VARLIST and conditionally evaluate BODY.
    Like `when-let*', except if BODY is empty and all the bindings
    are non-nil, then the result is the value of the last binding.

IOW the only time it's different from `when-let*` is when BODY is empty,
i.e. its only "feature" compares to `when-let*` is that

    (and-let* (..BINDINGS..
               (last (binding))))

is equivalent to

    (and-let* (..BINDINGS..)
      (binding))

Why would anyone write the first instead of the second, other than out
of masochism?  Can we kill/deprecate this?
[ I think we have too many (if|when|and)-let(*) for our own good: we
  should pick some winners and deprecate the other ones.   ]

I could see a use for something called `and-let(*)` but without a BODY,
for the purpose of remove a level of parens and indentation:

    (and-let*
      (x1 (foo1))
      (x2 (foo2)))

i.s.o

    (and-let*
        ((x1 (foo1))
         (x2 (foo2))))


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