The difference between equal and exactly equal word comparison operators explains the difference, but the important question also arises: what should I use when I do not compare floats with other things?
Erlang Pragmatic Programming recommends =: = and says that you should be suspicious of == and use it only when working with float. However, he also says that many existing codes do not follow this rule.
So, I have a little dilemma. Should I use "==" (even if not comparing floats with other values) for consistency with the surrounding code? Should I use "=: =" if necessary, even if it is incompatible with the rest of the file? Do I have to convert other expressions to a file in order to use "=: ="?
What are the tradeoffs? Is any operator more efficient than the other? If one of the operands is guaranteed not to be a number, does it matter which one I use? Are there any hidden traps (say, special float values ββsuch as NaN, Inf, etc.), if Erlang supports them).
By the way, the code base I came across is ejabberd.
source share