Mon Feb 10 12:29:01 CET 2003
Joe Armstrong <joe@REDACTED> writes:
> On Sat, 8 Feb 2003, Robert Virding wrote:
> I entirely agree - this violates the "principle of least surprise"
> my intuitive understanding of "+" is that it is a thing that adds
> *numbers* together - nothing else.
> <aside> Robert and I agonized for months over whether "+" should
> overload floats and integers - we made (of course) the wrong decision
> allowing arbitrary mixing of floats and integers with the appropriate
> coercions where necessary. This sucks since coercing a very large
> integer (bignum) into a float can fail etc. - too late now.
I think that "principle of least surprise" says that you should be able
to freely mix integers and floats.
In my opinion, the decision was correct. It does make it harder to
write a compiler, but it makes it (a lot) easier for the user.
I find the overloading of the size/1 BIF (tuples/binaries) to be much
worse. It prevents optimizing most uses of size/1, and is not significantly
easier for the user than two separate size BIFs would be.
Björn Gustavsson Ericsson Utvecklings AB
+46 8 727 56 87 125 25 Älvsjö
More information about the erlang-questions