Why do some people shun `if`?
"Michael P." <[email protected]>
| Newsgroups | gmane.comp.lang.erlang.general |
|---|---|
| Message-ID | <20210814234458.7c1c9ceb@aesop> |
I once stumbled over someone's Erlang style guide,
they wanted no `if`.
It was not very well explained why,
and there was no obvious e-mail address,
or I wanted to first do
some thorough thinking about it.
Now I have no more than this:
Is if not merely "syntactic sugar" for
a fun/0 with guarded clauses?
```
Now_this_is = (fun If() when Guard_seq_1 -> Expr_seq_1
%% On and on and on
; If() when Guard_seq_N -> Expr_seq_N
end)(),
% or:
Worst = case true
of true when Guard_seq_1 -> Expr_seq_1
; true when Guard_seq_2 -> Expr_seq_2
end.
```
What could be perceived as wrong with `if`?
~M
--
But who will test the tests?