[squeak-dev] Re: Immutability (was Re: About String vs Symbols)
Paolo Bonzini
bonzini at gnu.org
Wed Jul 30 16:05:57 UTC 2008
> This seems like a good idea and I tried it in the late 80's in BrouHaHa
> but it ends up being extremely clumsy. For example, if 'foo' is an
> instance of ImmutableString then every time one stores a mutable string
> one has to store it as e.g. 'foo' asString or as String with: $f with:
> $o with: $o etc. ALternatively if 'foo' is an instance of String
> (mutable) then when you print out a literal it prints as 'foo'
> asImmutableString, etc.
In GNU Smalltalk I don't have separate mutable/immutable strings, but
storing a mutable string with #storeOn: will indeed produce something
like "'foo' copy"; it was actually done to fix bugs.
There is a separate #storeLiteralOn: method used by the pretty-printer
that omits the #copy message send, and prints a ##(...) compile-time
expression if it is fed an arbitrary object.
Paolo
More information about the Squeak-dev
mailing list
|