[erlang-questions] if-elseif-else trick
Donald Steven
t6sn7gt@REDACTED
Wed Feb 20 14:16:41 CET 2019
I don't think:
-define(true,else).
yielding ?else ->
is much of an improvement.
Why not just allow the keyword else as a synonym for true when its usage
would improve the readability? (At times, "true" reminds me of trying to
read (SAT-like) sentences like: "Whenever he couldn't think of whether
or not he might have forgotten to turn the light on or off, or not.")
On 2/19/2019 6.23 AM, Mikael Pettersson wrote:
> 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".
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
More information about the erlang-questions
mailing list