Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
How to make an object read-only
Last updated at 6:27 pm UTC on 26 March 2018
Eliot Miranda
Mon, Mar 26, 2018 at 4:09 PM
To: The general-purpose Squeak developers list


There is a per-object flag (a bit in the object header) that if set prevents modification.

The bit is controlled by

 Object>>#setIsReadOnlyObject: 

with

 Object>>#beReadOnlyObject

as a convenience.

 Object>>#beReadOnlyObject 

is the getter. By default the bit is off (new objects are mutable).

The Compiler modification sets the bit for method literals (literal strings, symbols, arrays, byte arrays and boxed floats). The facility may also be used for
etc