I am curious why the comma ‹,› is a shortcut for and
and not andalso
in guard tests.
Since I'd call myself a “C native” I fail to see any shortcomings of short-circuit boolean evaluation.
I compiled some test code using the to_core
flag to see what code is actually generated. Using the comma, I see the left hand value and right and value get evaluated and both and'ed. With andalso
you have a case block within the case block and no call to erlang:and/2
.
I did no benchmark tests but I daresay the andalso
variant is the faster one.