Identity vs equality (was Re: [Newbies] Assignment)

Andreas Raab andreas.raab at gmx.de
Sat Aug 11 18:59:45 UTC 2007


stephane ducasse wrote:
>> In 3.10 they both evaluate to true.
> 
> Why does it make sense?

Symmetry. If foo = bar but bar ~= foo you end up in strange situations. 
Like here:

s1 := Set new.
s1 add: #foo.
s1 add: 'foo'.

s2 := Set new.
s2 add: 'foo'.
s2 add: #foo.

Do you expect these sets to have the same number of elements? If so, you 
better make sure comparisons are symmetric.

> I do not understand why #'hello' as a symbol should be = to 'hello'.

Because 'hello' is equal to #'hello' as a symbol.

> It would have been good that such an important change would have been 
> discussed on the mailing-list.

It has. Before your time. The original version of the method has a stamp 
saying "di 4/11/2000". And if you look at the archives of Squeak-dev in 
the second half of 2000 I'm sure you'll find the discussion.

Cheers,
   - Andreas



More information about the Squeak-dev mailing list