Stef,
why should strings be immutable, and why blame the compiler.
I'm not saying that. I'm saying that since strings are not immutable then the compiler should not optimize the strings in a compiled method.
The same situation is, for example, with Associations. In order to prevent mutation, someone invented ReadOnlyVariableBinding.
Literals have nothing much to do with compiler optimization, see senders of #encodeLiteral:, just with determining the correct bytecode for pushing them onto the stack.
But of course the compiler could emit code for always copying string literals, if you can afford the performance penalty.
As Bert wrote: it's normal :)
[Okay okay other languages have immutable string, but this is Smalltalk.]
This is not my point.
do you think that from a language point of view this is good to say
ok two strings are not identical if they are typed in different methods but if there are typed in the same methods they are identical?
This is why I got some of my slides not working when I switch from Visualworks to Squeak I do not have an old version of visualworks but it seems that they were consistent with the view they offered to strings to programmers. and consistent is important.
Stef