GNU bug report logs -
#67669
29.1; Drop text suggesting using `and' to replace `if'
Previous Next
Reported by: Xiyue Deng <manphiz <at> gmail.com>
Date: Wed, 6 Dec 2023 21:48:01 UTC
Severity: normal
Found in version 29.1
Done: Xiyue Deng <manphiz <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Hi Drew,
Drew Adams <drew.adams <at> oracle.com> writes:
>> 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.
Agreed here. I was quoting the SE answer for the "pure function" part,
but indeed I also think what matters is whether we use the results.
>
> 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.
Also agreed. And I've since closed this. Thanks for the discussion!
--
Xiyue Deng
This bug report was last modified 1 year and 224 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.