|
From: Cees de G. <cg...@cd...> - 2004-04-09 12:02:27
|
> 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> Object>>beImmutable: aBoolean <primitive...> that's probably all support you'd need, an extra bit and some code in #primitiveInstVarAtPut. I'm using this feature in VisualWorks to support automatic dirty marking, and it is really nice - it allows you to build very complex persistent object models that you'd normally avoid because of the dirty marking hassles. |