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 #180 received at 73853 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Sean Whitton <spwhitton <at> spwhitton.name>
Cc: Michael Heerdegen <michael_heerdegen <at> web.de>, 73853 <at> debbugs.gnu.org
Subject: Re: bug#73853: 31.0.50; and-let* is useless
Date: Sat, 18 Jan 2025 09:15:33 -0500
> As it's a readability aid, it doesn't have to be used absolutely
> everywhere to be useful.

For if/when/and there are *other* reasons to have those three
(e.g. a 4-way `and` becomes much more indented&ugly when replaced by
ifs/whens), so since we have them and since they overlap in many cases,
it can make sense for people to try and convey the intention of
their code by choosing one over the other when they can be
used interchangeably.
But this extra intention information was never the reason to have all three.

For `and-let` vs `when-let` there is no other reason to have both: every
`and-let*` can be replaced by a `when-let*` with virtually no difference
(and in practice all `and-let*` I ever found could similarly be replaced by
an `if-let*`), other than this act of conveying an intention.

> I think you are letting the perfect be the enemy of the good, in your
> thinking, here.

No, I'm trying to argue that `and-let*` is useful only because it
exists, whereas I think we should limit ourselves to things which exist
because they're useful.

If we had an alias of `let` called, say, `do` that behaved exactly the
same, people would likely be tempted to use it to convey the idea that
it doesn't return a value.  And then if I were to point out it's useless
I'd apparently see the exact same resistance I'm getting now.


        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.