[squeak-dev] Re: About String vs Symbols

Paolo Bonzini bonzini at gnu.org
Wed Jul 30 16:02:04 UTC 2008


>     Eliot, I read your answer and (like Colin probably) I didn't
>     understand if you were speaking about immutable objects in
>     Smalltalk, or of immutable strings (as in Java, where you have
>     immutable java.lang.String objects and use java.lang.StringBuffer to
>     obtain a restricted kind of mutability).
> 
> So java strings are not really immutable but they don't provide a 
> mutability API?

No, java strings are immutable (because they are in a final, i.e. not 
inheritable class, and don't provide a mutability API).

A java.lang.StringBuffer object is substantially a mutable, growable 
String even though it is 99% of the time used the same way as a 
Smalltalk WriteStream.  But the StringBuffer is not polymorphic with 
Strings: sooner or later however you'll have to convert the StringBuffer 
to a String to pass it to methods expecting a java.lang.String.

Paolo



More information about the Squeak-dev mailing list