[erlang-questions] newbie: equality
Jonathan Amsterdam
jbamsterdam@REDACTED
Fri Dec 28 16:11:18 CET 2007
Two comments on equality in Erlang.
1. The Reference Manual says that the only difference between == and
=:= is that the former will coerce ints to floats. (By the way, the
sentence that expresses this says "All comparison operators except =:=
and =/= are of type coerce". That isn't grammatical English, unless
"of type coerce" is some term of art that I don't know.) Why then does
Joe Armstrong in his book strongly advise using =:= in most cases? Is
it just the slight performance hit or is there a deeper reason?
2. It seems (from my experimentation) that =:= performs an initial
pointer-equality check. This is good and expected, but I think it
should be documented in the reference manual (i.e. made part of the
language semantics). Although it is in one sense just an efficiency
hack, it can have a dramatic effect on how one codes. E.g. I need a
list of key-value pairs suitable for use with lists:keysearch and
friends. May I use large objects for the keys, or must I use small
unique IDs instead?
More information about the erlang-questions
mailing list