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

Philippe Marschall philippe.marschall at gmail.com
Sun Aug 12 19:41:41 UTC 2007


2007/8/12, Andreas Raab <andreas.raab at gmx.de>:
> stephane ducasse wrote:
> > But I'm confused do you imply that the order in which the elements were
> > added had an impact on the set?
>
> Yes.
>
> >
> > in VisualWorks
> >
>
> Well, but in VisualWorks also:
>
> String>>= aString
>         "Answer whether the argument is a string, and is not a symbol,
>         and the receiver's size is the same as aString's size, and each of the
> receiver's
>         elements equal the corresponding element of aString"
>
>         | size |
>         aString isString ifFalse: [^false].
>         aString isSymbol ifTrue: [^false].
>         (size := self size) = aString size ifFalse: [^false].
>         1 to: size do:[:index | (self at: index) = (aString at: index) ifFalse:
> [^false]].
>         ^true
>
> So in other words, in VisualWorks Strings and Symbols always compare
> false which is perfectly symmetric.

Just happens to be opposite of Squeak. Ah the joys of portable
Smalltalk code. BTW GST does it the same way as VW.

Cheers
Philippe



More information about the Squeak-dev mailing list