[erlang-questions] Use of logical "not" in `case`
zxq9@REDACTED
zxq9@REDACTED
Sun Feb 11 12:54:52 CET 2018
On 2018年2月12日月曜日 0時48分56秒 JST Richard O'Keefe wrote:
> (a) I don't care whether false precedes true or true precedes false.
> (b) I *definitely* get confused by 'not'. Human beings in general
> are stunningly bad with 'not'. Empirical studies have shown
> that programmers are not good with it either.
> (c) I have learned to be wary of 'boolean'. Long experience teaches
> me that either there are more than 2 possibilities, or that there
> is more to say one at least one case, and often both. Here I
> would erase from my memory all trivial fond memories of maps:is_key/2
> and write
> case maps:find(Thingy, Map)
> of {ok, _Old_Value} -> ...
> ; error -> ...
> end
> so that there was no doubt about which branch was which.
> Seriously: your grandfather had to use IF and COND a lot when he
> wrote Lisp, but *we* have pattern matching.
> (d) In fact, we really do have pattern matching, so here
> case Map
> of #{Thingy := _} -> ...
> ; _ -> ...
> end
> perfectly expresses our intent.
Indeed! The sentiment seems universal.
Thanks to everyone who took the time to explain their opinion on it.
Eventually I'll probably compile a style guide from the various cases
of "is this annoying or not" sort of style questions I've asked here
over the last several years.
Eventually.
- Craig
More information about the erlang-questions
mailing list