[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: `when' vs. `and' / `unless' vs `or'
From: |
Drew Adams |
Subject: |
RE: `when' vs. `and' / `unless' vs `or' |
Date: |
Tue, 16 Oct 2018 15:13:16 -0700 (PDT) |
Do whatever you like. ;-) Different people use different styles.
There is no standard or even a convention. Common Lisp
suggests some conventions, but there too there is nothing
official.
I use `when' and `unless' when I want to show a human
reader (mainly me) that the code doesn't use or care about
the return value. I don't use them when the returned `nil'
could be important.
I use `and' or `or' when the return value is significant.
(With `not' as needed.)
I use `if' when the true part is a single sexp. If necessary,
to respect this I flip the true and false parts (negating the
condition).
I use `cond' when I have two or more sexps for each of
the true and false parts or I have more than two conditions.
I use `case' when the conditions would just test the
same symbol for equality against different values.
I don't use `pcase' much. Nothing against it, really.
Yes, the way I use `if' etc. can mean that I change which
form I use as the code evolves. I'd rather spend more
time fiddling with the code, in order to have the result
be easier to understand (for a human).
YMMV.
- `when' vs. `and' / `unless' vs `or', Garreau, Alexandre, 2018/10/16
- RE: `when' vs. `and' / `unless' vs `or',
Drew Adams <=
- Re: `when' vs. `and' / `unless' vs `or', Garreau, Alexandre, 2018/10/16
- RE: `when' vs. `and' / `unless' vs `or', Drew Adams, 2018/10/16
- Re: `when' vs. `and' / `unless' vs `or', Garreau, Alexandre, 2018/10/16
- RE: `when' vs. `and' / `unless' vs `or', Drew Adams, 2018/10/16
- Re: `when' vs. `and' / `unless' vs `or', Garreau, Alexandre, 2018/10/16
- RE: `when' vs. `and' / `unless' vs `or', Drew Adams, 2018/10/16
- Re: `when' vs. `and' / `unless' vs `or', Garreau, Alexandre, 2018/10/17
- Message not available
- Re: `when' vs. `and' / `unless' vs `or', Emanuel Berg, 2018/10/17
- Re: `when' vs. `and' / `unless' vs `or', Michael Heerdegen, 2018/10/17