[squeak-dev] Immutability (was Re: About String vs Symbols)

Eliot Miranda eliot.miranda at gmail.com
Tue Jul 29 22:07:15 UTC 2008


On Tue, Jul 29, 2008 at 2:11 PM, Hans-Martin Mosner <hmm at heeg.de> wrote:

> Philippe Marschall schrieb:
> > 2008/7/29 Eliot Miranda <eliot.miranda at gmail.com>:
> >
> >> On Tue, Jul 29, 2008 at 1:03 PM, Janko Mivšek <janko.mivsek at eranova.si>
> >> wrote:
> >>
> >>> Hi Eliot,
> >>>
> >>> Does that mean that you are introducing immutability in new Squeak VM
> you
> >>> are working on? Well, that would be really nice!
> >>>
> >>
> >> I think that's up to the community.
> >>
> >
> > Wouldn't that break a lot of code? Like anything that does WriteStream
> > on a String like #streamContents: ?
> >
> No, unless you're doing WriteStream on: '' which you should not do anyway.
> Normal Strings (those that are created with #new: or with copying) are
> mutable, just as they are now.
> In general, any code that breaks when the immutability of literals is
> ensured by the VM was broken to begin with...
>

+1.

Its trivial to fix such code.  e.g. if you have
      (ReadWriteStream with: 'The date is ') print: Date today; contents
you simply change it to
      (ReadWriteStream with: 'The date is ' copy) print: Date today;
contents
and you're done.

Some developers in the VW community complained when we introduced
immutability in 2002 about exactly these cases.  But the fuss soon died down
as people realised that indeed their code was safer with the change.


> Cheers,
> Hans-Martin
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20080729/d3e0d526/attachment.htm


More information about the Squeak-dev mailing list