|
From: Hans-Martin M. <hm...@he...> - 2004-04-09 12:33:02
|
Cees de Groot wrote: >>Immutability bit >>This sounds intriguing. Has anyone here thought seriously about what is needed to support it? >> >> >> >Well, as far as you can classify my thinking on this subject as being serious (me being a total nitwit in this area), pseudocode-wise it would be: > >Object>>instVarAt: anInteger put: anObject > self isImmutable ifTrue: [ > AttemptToWriteImmutableObjectException new > receiver: self; > index: anInteger; > value: anObject; > raise]. > <original code> > > > > The instVarAt:put: primitive (and the at:put: primitive for indexed access) can just check the immutability bit - the additional overhead should be small. The inst var assignments in methods are more complicated. One possible optimization would be to allow immutability only for old objects - when assigning into old objects, we need additional code anyway. The beImmutable primitive would make sure that the receiver is either old already, or it would move the oldspace boundary to point after the objects. Does that sound sane? Cheers, Hans-Martin |