GNU bug report logs -
#73853
Should and-let* become a synonym for when-let*?
Previous Next
Full log
Message #186 received at 73853 <at> debbugs.gnu.org (full text, mbox):
> OTOH, `when-let' executes expressions when some condition(s) are met.
> The return value is not significant most of the time, but in particular
> not when the condition was not met.
[ I can't think if a situation where the return value would be
significant when the condition is true but not when it's not.
Either the context uses the return value or it doesn't, AFAIK.
It's rather unusual for the context to use it in a way that depends
on the condition (it would require the context to make a similar and
thus somewhat redundant test). ]
> To rely on the implicit `nil' return value of `when-let' to use it in
> a condition is not good style IMHO. Like relying on the nil return
> value of `while'. You can do it and "it's clear" but I hate it. Ok?
That goes back to my earlier question: what makes `and/when/if-let` so
different from `ignore-errors` and so many other constructs.
> So, if `and-let' would be removed I would replace it with either
> (if-let (TESTS...) BOOL-EXP nil) or
> (let (VARS) (and (setq VAR1 TEST1) ...)).
Fine by me.
> If this is so much better for users like you I don't know.
> It's surely still worse for me.
Then write it with `when-let` and get used to the idea that it returns
a value, because... well, it does and code out there relies on it (a
small random sampling suggests that around 15% of the existing uses in
Emacs do).
> There is a third option btw: remove `when-let' instead of `and-let'.
`grep` suggests that will not be popular.
At least in Emacs + (Non)GNU ELPA, we're talking 233 vs 3093.
> Since `when-let' is mostly `if-let' with a only a tiny difference that
> doesn't let you do anything new...people not really obey using `when'
> when there is no "else"...it's so similar to `and-let'... most of your
> arguments are transferable 1:1.
I don't have a strong preference either way.
I just know that they're redundant and would rather see one of the two disappear.
If none of them can't be removed, I'd actually prefer them to be actual
aliases of each other, so at least ELisp non-specialists don't need to
learn the subtle differences between the two.
Stefan
This bug report was last modified 141 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.