In erlang 'and' has higher priority than comparisons. So 'is_integer(X) and X > 0' is interpreted as '(is_integer(X) and X) > 0'. 'andalso' has lower priority than comparisons so it is interpreted as we expect.
I really don't understand the aversion?, lack of use? of parenthesis. Back in college (before C++ was released to give you time scale) some C class, spent a lot of time on operator precedence. I was like, why bother? Just use parens, be explicit, clear and never ever have to learn or be bit by any language's precedence ever!<p>Ever.
Just FYI. Brujo is close to being expert in Erlang. This post is a more of a "warning for juniors" than "damn, today I've discovered something new".<p>And there is nothing really WAT about it. Just part of rather simple Erlang language grammar.
I always use ',' and ';' in guards. Maybe I'm weird but it feels wrong using the short-circuit operators knowing that guards are always short-circuited anyway. Also they take up too much space :)
Reminded me of `and`, `or`, etc. precedence in PHP, e.g. <a href="http://php.net/manual/en/language.operators.precedence.php#117390" rel="nofollow">http://php.net/manual/en/language.operators.precedence.php#1...</a>