I am learning Erlang from the LearnYouSomeErlang web-book. One thing that struck me while learning was the non short-circuiting boolean conjunction and disjunction operators viz; and
and or
. What are the use cases for these operators? Why would you want to use them instead of andalso
and orelse
?
It used to be (until R13A) that andalso
and orelse
weren't tail recursive. See http://www.erlang.org/eeps/eep-0017.html for details. I don't think there is a good reason to use and
/or
in new programs.
I see them as doing different things and use them as such:
and
/or
as logical operators where I want to compare the logical values. As they are strict I automatically get type-checking and I KNOW exactly what has been called.andalso
/orelse
for control, much like &&
and ||
in C.Seeing errors are defined in erlang I feel it is good to know what has been executed and how it went.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With