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

greim greim@REDACTED
Mon Jul 23 16:01:13 CEST 2018


"Programs must not regarded as code for computers,
but as literature for humans"

Nicklaus Wirth, Turing Award 1984

.......
so whats your opinion about:

Msg /= undefined maybeornot io:format("Message: ~s~n", [Msg]),

or much more readable and clear with a well defined operator, because we 
have a functional language:

Msg /= undefined F@*#! io:format("Message: ~s~n", [Msg]),

Markus Greim

Am 23.07.2018 um 15:32 schrieb Dmitry Belyaev:
> How does it mess with types? The andalso and orelse operators should 
> only care about the type of the first operand and it always is boolean.
> 
> I personally don't like list comprehension as brackets create additional 
> noise and might not be obvious to other developers.
> 
> Also dialyzer may complain about unused value in either of ways, so the 
> cleanest is probably case or if. The latter in Elixir doesn't require 
> else branch which reduces noise a little bit.
> 
> On 23 July 2018 21:05:37 GMT+10:00, Jesper Louis Andersen 
> <jesper.louis.andersen@REDACTED> wrote:
> 
>     On Sun, Jul 22, 2018 at 9:09 PM Jachym Holecek <freza@REDACTED
>     <mailto: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.​
> 
> 
> -- 
> Kind regards,
> Dmitry Belyaev
> 
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
> 




More information about the erlang-questions mailing list