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

Andrew Tween amtween at hotmail.com
Fri Aug 10 14:40:12 UTC 2007


"Göran Krampe" <goran at krampe.se> wrote in message 
news:65054.194.213.87.193.1186754721.squirrel at webmail.krampe.se...
> Hi!
>
>> For sure, #== has been used with Symbols which can compare really fast
>> instead of enumerating characters...
>>
>> But since in modern Squeak 'Hello' = #'Hello', i'am not sure that old
>> style optimizations #== don't introduce bugs now...
>>
>> Nicolas
>
> Hmmm, odd:
>
> 'Hello' = #'Hello' -> true
>
> #'Hello' = 'Hello' -> false
>
> ...that seems to indicate something is a bit wrong. ;)
>
> regards, Göran

In 3.10 they both evaluate to true.

But what about this....

d := Dictionary new
 at: 2 put: 10;
 at: 2.0 put: 100;
 yourself.
          ->   a Dictionary(2->10 2.0->100 )

d:=Dictionary new
 at: #a put: 10;
 at: 'a' put: 100;
 yourself.
        ->     a Dictionary(#a->100 )

2 = 2.0 and #a = 'a' , so why the difference ?

2 hash = 2.0 hash -> false (shouldn't this be true?)

---
I recently modified Shout to use == instead of = when comparing a character 
from the input stream to a literal char ( e.g. next == $- ). It produced a 
measurable speed-up; but now I am feeling guilty ;)
----
Cheers,
Andy 





More information about the Squeak-dev mailing list