Blake schrieb:
On Sun, 28 Oct 2007 01:32:34 -0800, Michael Davies mykdavies+squeak@gmail.com wrote:
There's an interesting post and discussion here: http://weblog.raganwald.com/2007/10/too-much-of-good-thing-not-all.html
I know we wrestle with symmetry from time-to-time but is it true that:
1 + 2.0
should yield the same result as
2.0 + 1
?
For the current arithmetic implementation in Smalltalk, yes (in either case the integer is converted to a float, and those two floats are added. Floating point addition is commutative).
In general, a + b can be unequal to b + a, for example, if you implement the #+ method in class String to mean concatenation. Even in mathematical notations, there are operator symbols which are commutative when used with scalars and non-commutative when used with other mathematical objects.
Cheers, Hans-Martin