immutability and become (Was: Re: [squeak-dev] immutability)
markuslampert at yahoo.com
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.
----- 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 gmail.com"
> href="mailto:siguctua at gmail.com">siguctua at gmail.com> wrote:
> 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.
> problem is following:
> suppose your object (a) is referencing object
> now you doing:
> a beImmutable.
> 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
> immutability, using #become..
> Best regards,
> Igor Stasenko AKA sig.
> 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