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

Andrew Tween amtween at hotmail.com
Fri Aug 10 17:10:45 UTC 2007


----- Original Message ----- 
From: "Lukas Renggli" <renggli at gmail.com>
Newsgroups: gmane.comp.lang.smalltalk.squeak.general
To: "The general-purpose Squeak developers list"
<squeak-dev at lists.squeakfoundation.org>
Sent: Friday, August 10, 2007 5:14 PM
Subject: Re: Identity vs equality (was Re: [Newbies] Assignment)


>> 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 ;)
>
> Please note that:
>
>    (Character value: 6543) == (Character value: 6543) -> false

Noted.

>
> This will break as soon as you use WideString as source-code. I had to
> modify the runtime and compiler of SmaCC to send #= to characters to
> fix some subtle bugs.

No. It think it will still be ok.

((((Character value: 6543) asString , $- asString) at: 2) == $- ) -> true

I only have literal chars on the right hand side of the ==.
Literal chars can only be < 256 , and are unique.
If they stop being unique, so (Character value: 32) == (Character value:
32) -> false, then you will be right.

Cheers,
Andy

>
> Cheers,
> Lukas
>
> -- 
> Lukas Renggli
> http://www.lukas-renggli.ch
>
>





More information about the Squeak-dev mailing list