Changing strings

jennyw jennyw at dangerousideas.com
Sun Apr 21 20:33:55 UTC 2002


I'm just getting back into Smalltalk after 10 years, so please pardon me
if this is a well-known topic.

a := 'squeak'.
'squeak' at: 6 put: $l.

I've noticed that the above code results in a equaling 'squeal'. This 
seems kind of strange to me.  It seems that literal strings, like symbols, 
are unique?  I'm not certain, but I don't think all Smalltalks are like 
this.

I did notice that:

a := 'squeak'.
b:= 'squeal'.
'squeak' at: 6 put: $l.
a == b.

returns false, so I guess it may not be a problem very often.  
Nonetheless, I find it disturbing that if a an instance variable is 
initialized using a string literal, and if a user knows what that string 
literal is, then the user can change the value of that instance variable 
without an accessor.

Any comments?

Thanks!

Jen



More information about the Squeak-dev mailing list