identity and equivalence in Squeak

shane at shane at
Thu Feb 13 16:08:28 UTC 2003

I am learning Squeak (and Smalltalk) for the first time,
and I am reading Stephane Ducasse's forthcoming book on 
Squeak, "Learning Programming in Squeak".

Section 5.2 of Chapter 1 discusses  equivalence and identity
of strings and symbols in Squeak.

In a Workspace window I am doing a printit ( Alt-p ) of the
following lines:

'aaa' == 'aaa'
'aaa' = 'aaa'
#aaa == #aaa
#aaa = #aaa

which produces:

'aaa' == 'aaa' true
'aaa' = 'aaa' true
#aaa == #aaa true
#aaa = #aaa true

I thought the first line should produce:
'aaa' == 'aaa' false

since 'aaa' and 'aaa' are equal but not identical (not the same 
object).  Or perhaps they are, in the compiler?
Since they are the same literal constants.

The book says to try these but does not say what the results should 

On the other hand:

a := 'aaa'
b := 'aaa'
a = b
a == b


a = b false
a == b false

I thought:
a = b

should produce:
a = b true

because a and b are equal (for string comparison) though not 
identical (the same object).

Can anyone tell me what I am missing here?

The book says:
"Try: ’aaa’ == ’aaa’ and #aaa == #aaa."


More information about the Squeak-dev mailing list