immutability and become (Was: Re: [squeak-dev] immutability)

Markus Lampert markuslampert at
Thu Mar 18 04:51:49 UTC 2010

I would have assumed that an immutable object cannot become anything else. Neither any other object, nor another immutable object. If you can change the state of an object in any way, either by changing it's state directly or by ex-changing it with another object, I would not consider it 'immutable'.

SmallInteger seems to be an immutable object, although probably more a constraint than a design decision.

Have fun,

----- Original Message ----
> As well, as i could simply do:

object isMutable ifFalse: [ object 
> becomeForward: object clone ].

And so, #become becomes a universal tool 
> to defeat an immutability.

On 18 March 2010 06:00, Igor Stasenko <
> ymailto="mailto:siguctua at" 
> href="mailto:siguctua at">siguctua at> wrote:
> Yes, 
> i am against adding immutability bit in VM.
> But if we going that 
> way, then please explain me how VM will respect
> immutability and 
> #become: or #becomeForward:
> at the same time.
> The 
> problem is following:
> suppose your object (a) is referencing object 
> (b).
> now you doing:
>  a beImmutable.
> and 
> then
> b becomeForward: c.
> which leads to 
> replacement of reference to (b) by reference to (c)
> in an object (a), 
> which is immutable.
> You could say, lets ignore this.
> Then, apparently , expect to see a hacky code, which as a workaround
> of 
> immutability, using #become..
> --
> Best regards,
> Igor Stasenko AKA sig.

Best regards,
> Stasenko AKA sig.

Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now

More information about the Squeak-dev mailing list