33: Freezing objects

  1. Locking an object
    1. Why you might want to lock an object.
    2. Lock an object by calling "lock" on the object.
    3. A locked object can't be modified.
      1. The locked object is first isolated (discussed under Ownership in the Processes section).
      2. A locked object treats all references to itself as protected references (discussed under Arguments in the Classes section).
      3. Unlock an object by calling unlockedCopy on it and then destroying the original.
  2. Freezing an object strips it of some of its properties so that the object can easily be transported to a new location. It also disables most of the object's ops and attributes so they can't be used.
    1. A public package at the origin place and a public package at the destination place must contain a copy of the object's class definition so that the object can be frozen and then thawed. The object's features are restored when it is thawed, either at the origin or at the destination.
    2. Because the object definition can change in some aspects between the origin and the destination, freezing allows a programmer to swap classes between origin and destination.
  3. The freezing process
    1. Before an object may be frozen, it must first be locked (and hence isolated).
    2. Call freeze on the object (through its PackageProcess mix-in). You must own the object.
      1. Specify the packages where a matching object may be stored.
        1. Nil specifies all packages.
        2. A set of package telenames followed by notInPackage false specifies all packages in the set.
        3. A set of package telenames followed by notInPackage true specifies all packages not in the set.
    3. All of the object's properties (except those listed later) are replaced with the assigned telename and a key: the telename of the package that includes the matching object, and the key associated with that object.
    4. If the frozen object is a class, its properties are replaced with its series name, not the package and key.
    5. If the object to be frozen is unlocked or it doesn't have a match in the specified dictionaries, freeze is attempted on each of the object's properties, including its class. This allows a single freeze operation to freeze a number of objects within a single closure.
  4. A frozen object is restricted in operation. It can perform the discard, isolate, protect, and ref operations. The attributes isFrozen, isLocked, isOwned, isProtected, and owner are available. Trying to use any other feature throws ObjectFrozen.
    1. If the frozen object is a class, its members all act as if frozen.
  5. Thawing an object
    1. Call thaw on the object and supply a set of dictionaries as you do for freeze.
    2. The names in the object's properties are replaced with objects from a match found in the specified dictionaries.
    3. If the object is not found in the specified dictionaries, thaw is called on each of its properties, including class.
  6. Providing a matching object in origin and destination packages
    1. The key for an object must match in the origin and destination packages.
    2. The value for the key can be different in the two packages, but in practice is the same.

    TS Ref - 26 JUN 1996

    Generated by the sweat of Mike Boom's brow.