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

stephane ducasse stephane.ducasse at free.fr
Sun Aug 12 18:27:59 UTC 2007


Thanks for the answer.

> 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.


But I'm confused do you imply that the order in which the elements  
were added had an impact on the set?

in VisualWorks

| s1 s2 |

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

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

So I have problem to understand what was the real problem: is Squeak  
set badly implemented?
Is VisualWorks that wrong? I think that these behavior are core and  
this is strnage that there is
a so big difference between two smalltalks

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

I'm sorry to look that terribly stupid but a string is not equal to a  
symbol. At least in VisualWorks this is clear

'Hello' = #'Hello'
	false

#'Hello' = 'Hello'
	false


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

I started to play with squeak before 2000 (around 1998). But  
certainly not following everything. I guess that I started on 2.3c  
which was crashing
on solaris.

> 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.

I will because I do not understand why a string is equal to a symbol.  
To me this is not because we use inheritance and that object have a  
similar (but not quite the same interface) that they are equal at  
least in VW and Lisp symbols and strings are not equal.
>
> Cheers,
>   - Andreas
>
>




More information about the Squeak-dev mailing list