PackageDescription: ImmutabilityCompatibility

Immutability Compatibility

Last published: April 4, 2002 by 'aknight'

Defines 1 Classes
Extends 3 Classes

This parcel is a simple set of overrides that provides certain forms of backward compatibility for immutability. The support is incomplete because the OE sets immutability for certain objects (primarily numeric computation results) without the ability to override. That is, there is no ObjectMemory setting that can tell the VM not to turn on the flag, as it tends to be embedded in the OE code as a literal for performance reasons.

What this change entails is methods that allow control of the immutability flag and override methods that set immutability based on the flag. Several of these occur in Number classes, so they may or may not have any effect. The others plug into CompiledCode (which makes literals and binding references immutable), NoModificationError (to control what happens on an exception), and UISettings (to permit setting the flag).

Two global variables are defined: Kernel.LiteralImmutability to control whether literals and numbers should be immutable, when we have control over them, and Kernel.MutationAction to control what happens on the exception. On loading the default values are #false (leave things mutable) and #simple (place a simple message in the Transcript, make the offending object mutable, and retry the action), which maintains the behavior of VW5i while giving an otherwise "silent" notification of the problem.