<div><div dir="auto">I don’t understand the strong answers.</div><div dir="auto">To me the semantics of orelse/and also are well known. They are even known as ||/&& in the mainstream. </div></div><div dir="auto">They have their use as the common boolean shortcut operators. They are even more than that:</div><div dir="auto">case ShouldOpen andalso file:open(...) of</div><div dir="auto">false -></div><div dir="auto">{error,_} -></div><div dir="auto">{ok,_} -></div><div dir="auto">end</div><div dir="auto"><br></div><div dir="auto">These operators are very interesting semantics. Erlang is not exactly a pure language. Being able to express side effects in such an easy-to-comment amount of code that’s just priceless. Here’s a legit example: <div><a href="https://github.com/2600hz/kazoo/blob/master/applications/tasks/src/kz_tasks_scheduler.erl#L526">https://github.com/2600hz/kazoo/blob/master/applications/tasks/src/kz_tasks_scheduler.erl#L526</a></div><div dir="auto"><br></div><div dir="auto">So why the big words? What’s next, the process dictionary, using list comprehensions with 1-element lists generators?</div><div dir="auto">To me if you don’t like this kind of code it’s only because you have not needed / seen it much. So, read more code?</div></div><div><br><div class="gmail_quote"><div dir="ltr">On Tue 24 Jul 2018 at 05:42, <<a href="mailto:zxq9@zxq9.com">zxq9@zxq9.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 2018年7月22日日曜日 14時25分00秒 JST Viktor Söderqvist wrote:<br>
> Hey everyone,<br>
> <br>
> I've seen these short-circuit operators with a non-boolean second<br>
> operand, usually where the second operand is doing some side-effect and<br>
> the return value is not important. It seems to be a trend. Example:<br>
> <br>
>     Msg /= undefined andalso io:format("Message: ~s~n", [Msg]),<br>
> <br>
> I this good or bad style?<br>
<br>
That code should die in a fire and the author should say repent with<br>
the chanting of 100 Hail McCarthys.<br>
<br>
-Craig<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div><br></div><div>Cheers,</div><div>-- </div><div>Pierre Fenoll</div></div><div><br></div></div></div>