Closed kilianmh closed 1 month ago
If we add this, I think if should probably be as if-not-let
, and we should probably also add if-not
.
Do you have any examples of a situation where this macro could be useful? Nothing comes to mind for me.
Do you have any examples of a situation where this macro could be useful?
Use case:
then-form
else-form
Here dummy code to showcase the difference if-let
vs if-not-let
:
(if-let
(variable-1 initial-form-1)
(
.
.
.
.
.
)
(error-resulting-from-variable-1-nil))
And here written with if-not-let
(if-not-let
(variable-1 initial-form-1)
(error-resulting-from-variable-1-nil)
(
.
.
.
.
.
))
With if-not-let
, the error is next to the code that caused it.
Especially with multiple nested if-let
forms of this structure
the code is more readable when replaced by if-not-let
.
we should probably also add
if-not
I guess, yes.
Interesting. I actually hadn't realized if-let
bindings were in effect in the else clause. In that case I think the idea makes sense if you want to go ahead with a PR for if-not
and if-not-let
.
While using
if-let
I want the then clause to execute when one or all variables evaluate tonil
. Currently with if-let that is not possible. To achieve that we can copy the code fromif-let
in alexandra and simply change this line fromto
Do you like the idea of adding this macro? If yes, then the name could also be
not-if-let
,if-not-let
, orlet-if-not
.