[erlang-questions] learning Erlang: factoring primes
Mon May 7 23:28:36 CEST 2007
Bjorn Gustavsson wrote:
> ok <> writes:
>> In fact I just made this "mistake" in the improved factorising code I
>> posted. My excuse is that Erlang, which came *after* Prolog and which
>> uses Prolog-based syntax, gets =:= and == completely back-to-front from
>> the way Prolog has them. In Prolog, == means "exact identity" and
>> =:= means "numerically equal after evaluation". I cannot imagine why
>> Erlang swapped them. I keep on tripping up over this.
> I think that the reason is that floats was not originally in the Erlang
> language, but was added later.
Originally it was that. When floats were introduced we had a LONG
discussion on whether to have automatic type conversion of numbers for
numerical operators or not. Eventually we decided to do this and then it
was natural to do that in comparisons as well. Then we found we needed
the exact comparison to use in matching so it was added as an operator
available to users.
In retrospect we should have added the whole spectrum of term comparison
operators and given them a uniform appearance. Perhaps something like
@==, @/=, @<, @=<, @>, @>=.
We took alot from Prolog so why did we not use '\' in operators but use
'/'. Good question, next question.
I am still not 100% certain that having automatic type conversion of
numbers was a Good Thing. I know everyone else (or at least most) do it
and that it is usually convenient, but still ....
At least that is how I remember it.
More information about the erlang-questions