Navigation:  Welcome to Dolphin Smalltalk X6 > What's New in Version 6? > Compiler and Virtual Machine >

Immutability Support

Previous pageReturn to chapter overviewNext page

We've now made all compiler generated literal objects immutable, and any attempt to write to them will result in a Attempt to update read-only object error.

In addition, you can also mark any other object as immutable by sending it an #isImmutable: message with true as the argument. You might want to do this for shared constants variables such as class variables. Should you need to modify an immutable object then the Object>>whileMutableDo: method can be used to temporarily disable immutability while a block is  executed.

The immutability mechanism can also be used as a guard mechanism to detect dirty objects since the VM now sends #errorInstVarAt:put: to an immutable object if one attempts to assign to its named instance variables.