bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#67669: 29.1; Drop text suggesting using `and' to replace `if'


From: Drew Adams
Subject: bug#67669: 29.1; Drop text suggesting using `and' to replace `if'
Date: Thu, 7 Dec 2023 19:37:30 +0000

> I quite like this suggestion[1] that `if' and `when' are used to guard side
> effects,

More clearly, `when' and `unless' (not `if', which is general - no special 
suggestion) are used to suggest (to humans) that they're used _only_ to perform 
side effects.  With this convention, code shouldn't depend on their (always 
`nil') return value.

> whereas `and' and `or' are used for pure functions.

That too isn't really the convention (though it is what's said in that emacs.SE 
answer).

What should be said is that you use `and' and `or' when _the return value 
matters_, i.e., when it's used somewhere.

That does _not_ preclude the use of `and' and `or' to perform side effects.  
It's simply that the _return value matters_.  Unlike `progn', the (Boolean) 
return value of each of their "steps" (sexps) determines whether subsequent 
ones are evaluated.

I've added another answer to the emacs.SE question you cited:

https://emacs.stackexchange.com/a/79744/105

But as you correctly noted, such conventions are a question of personal (or 
group) coding style.  Lisp doesn't care or recognize any such meaning.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]