Object orientation - can you have too much of a good thing?
hmm at heeg.de
Mon Oct 29 06:53:28 UTC 2007
> On Sun, 28 Oct 2007 01:32:34 -0800, Michael Davies
> <mykdavies+squeak at gmail.com> wrote:
>> There's an interesting post and discussion here:
> 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.
More information about the Squeak-dev