[erlang-questions] if-elseif-else trick

Mikael Pettersson mikpelinux@REDACTED
Tue Feb 19 12:23:57 CET 2019

On Tue, Feb 19, 2019 at 8:37 AM Viktor Söderqvist <viktor@REDACTED> wrote:
> The point of the ?elseif syntax trick is that it lets you write the
> nested case above as the flat structure:
> f() ->
>     ?'if'(g1())   -> a;
>     ?elseif(g2()) -> b;
>     ?elseif(g3()) -> c;
>     ?else         -> d.

So you've reimplemented LISP's COND.  Please just do it properly in
the Erlang parser (I belive 'cond' is already a reserved word), and
write an EEP for it.

FWIW, my code tends to be CASE heavy largely to avoid the inherent
problems of Erlang's limited guard expressions and butt-ugly "if".

More information about the erlang-questions mailing list