[erlang-questions] Orelse and andalso as short-hand for case

Dmytro Lytovchenko dmytro.lytovchenko@REDACTED
Mon Jul 23 13:20:48 CEST 2018


Just checked that a function is not created when you compile [X ||
condition] and it creates a check and a branch instruction.
Amazing.
Thanks for the tip.

2018-07-23 13:05 GMT+02:00 Jesper Louis Andersen <
jesper.louis.andersen@REDACTED>:

> On Sun, Jul 22, 2018 at 9:09 PM Jachym Holecek <freza@REDACTED>
> wrote:
>
>> # Viktor Söderqvist 2018-07-22:
>> >
>> >     Msg /= undefined andalso io:format("Message: ~s~n", [Msg]),
>> >
>> > I this good or bad style?
>>
>> It is horrible style. Pain to read, pain to modify, pain to reason about.
>>
>> Simple clear question deserves a simple clear answer. :-)
>>
>>
> ​I don't like the style either, mostly because it messes with the types.
> andalso and orelse expects boolean expressions, but the style used breaks
> that format. However, something like
>
> [x || Msg /= undefined]
>
> doesn't.​
>
>
> --
> J.
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180723/39e87b76/attachment.htm>


More information about the erlang-questions mailing list