[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: |
Sean Whitton |
Subject: |
bug#67669: 29.1; Drop text suggesting using `and' to replace `if' |
Date: |
Fri, 08 Dec 2023 10:45:18 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Hello,
On Thu 07 Dec 2023 at 09:49am -08, Xiyue Deng wrote:
> Agreed on the point of being educational, and of course in the end
> coding style is mostly a matter of personal preference. However, I
> would argue a bit that in such case we wouldn't need `if' or `when' at
> all as both can be emulated by `and' and `or' if you are careful enough.
> On the other hand, `if' and `when' should exist for a reason. I quite
> like this suggestion[1] that `if' and `when' are used to guard side
> effects, whereas `and' and `or' are used for pure functions.
> Interestingly the current example you quoted changed from using `and'
> (as in the old version I quoted) to `if' probably based on this
> reasoning. Similarly I wouldn't suggest to replace `if' with `and' in
> the original example around the text we are discussing:
It's an old Lisp convention, not Emacs-specific, to use 'and' for return
value and 'when' for side-effects, and not to use 'if' when there is no
'else' clause.
--
Sean Whitton
- bug#67669: 29.1; Drop text suggesting using `and' to replace `if', (continued)
- bug#67669: 29.1; Drop text suggesting using `and' to replace `if', Xiyue Deng, 2023/12/07
- bug#67669: 29.1; Drop text suggesting using `and' to replace `if', Eli Zaretskii, 2023/12/07
- bug#67669: 29.1; Drop text suggesting using `and' to replace `if', Xiyue Deng, 2023/12/07
- bug#67669: 29.1; Drop text suggesting using `and' to replace `if', Drew Adams, 2023/12/07
- bug#67669: 29.1; Drop text suggesting using `and' to replace `if', Xiyue Deng, 2023/12/08
- bug#67669: 29.1; Drop text suggesting using `and' to replace `if', Eli Zaretskii, 2023/12/08
- bug#67669: 29.1; Drop text suggesting using `and' to replace `if', Xiyue Deng, 2023/12/08
- bug#67669: 29.1; Drop text suggesting using `and' to replace `if', Drew Adams, 2023/12/08
- bug#67669: 29.1; Drop text suggesting using `and' to replace `if', Drew Adams, 2023/12/07
- bug#67669: 29.1; Drop text suggesting using `and' to replace `if', Xiyue Deng, 2023/12/07
- bug#67669: 29.1; Drop text suggesting using `and' to replace `if',
Sean Whitton <=
- bug#67669: 29.1; Drop text suggesting using `and' to replace `if', Xiyue Deng, 2023/12/08