25: Ownership and Closure

  1. An object's closure is a set of objects: the object itself, all objects used as its properties, and--recursively--all objects used as properties of the property objects.
    1. Note that attributes are commonly associated with a property that the getter and setter operations manipulate.
    2. Closure is important when determining the bounds of a complex object, especially necessary when an object travels to a new location.
    3. Closure is also important to determine the size of an object, and for determining whether or not you can pass a complex object by owner; you have to own the closure first.
  2. All objects in an engine place exist as separate and discrete entities. References bind them together. A complex object, made up of other objects, is simply an object with references to other objects.
    1. References are the "glue" of the object-oriented world of Telescript. They create complex structures of objects; they control interactions among objects.
    2. Every object has at least one reference. An object is destroyed by the engine if all owner references to it are dropped.
    3. A reference is directional: an object holding a reference can read and (if the reference is unprotected) manipulate the antecedent, but the antecedent can't know or manipulate the object unless it has a reference in turn to the object.
      1. Note that the responder can get a reference to the requester whenever an operation is called using the "client" selector.
    4. An object referred to is called an antecedent.
    5. A reference can be protected or unprotected. (Discussed in earlier chapter on passing arguments.)
      1. An unprotected reference (the default reference) allows an object to modify the antecedent (that is, to modify or replace objects in its closure).
      2. A protected reference does not allow an object to modify the antecedent.
    6. One object can hold duplicate references to another object.
      1. isSame (called on Object) allows an object to see if it has duplicate references to the same object.
    7. Creating a new reference
      1. When an object is created, its creator receives a reference to the newly created object. (This typically happens, in Telescript, in an assignment. The assignment binds the newly created object to the parent object.)
      2. Passing an argument or a result for an operation creates a new reference to an object.
      3. Assignments such as foo = bar; or foo = bar.protect(); create references to objects.
    8. Voiding a reference
      1. A reference is voided when its antecedent moves out of reference proximity (for example, it travels to a new place as part of an agent, or it belongs to an agent that is no longer meeting with the object's parent agent.)
      2. A reference is voided when the antecedent is isolated (discussed later) or destroyed.
      3. When the owner drops its reference to the antecedent, the non-owner references to the antecedent go void at the next garbage collection.
      4. Trying to use a feature whose reference is void will throw ReferenceVoid.
    9. Discarding a reference
      1. An object discards a reference to an antecedent when it calls "discard" on the antecedent.
  3. Copying an object
    1. Calling copy on an object
    2. A copy of an object is a copy of all of the object's properties as well, which means that all of the objects within a complex object are copied.
      1. Any Uncopied objects in the complex object aren't copied.
  4. All objects are owned by a process. Each process is owned by itself.
    1. The owner attribute of an object provides a reference to the object's owner.
    2. An object is uniformly owned if a single process owns the object and all of the objects within its closure.
  5. Object ownership establishes reference boundaries between places and agents.
    1. All objects must belong to either an agent or a place.
    2. Objects of one owner can only acquire references to objects of a second owner if:
      1. The first owner (a place or agent) is an occupant of the second owner (a place).
      2. The first owner (agent or place) and the second owner (agent or place) both occupy the same place. (Note that two non-meeting agents in the same place can't require references to each other's objects.)
    3. Objects with the same owner can always acquire references to each other.
  6. When an object of one owner has a reference to an object of another owner, the first object's owner borrows the second object from its owner. The second object's owner lends the object to the first object's owner. The ownership of both objects remains the same.
  7. When an agent travels or parts from a meeting (via go, send, part, or partAll, all described in an agent chapter), the processes involved are separating. Separation voids references between one set of objects owned by the agent and another set of objects owned by other processes.
    1. The engine separates an agent embarking on a trip by voiding references between the objects owned by the agent and objects owned by all other processes.
    2. The engine separates an agent from another agent from which it has parted by voiding references between the objects owned by the first agent and objects owned by the second agent.
    3. Any object partially owned by a separating process (the object is owned by one process, but one or more properties are owned by other processes) has its references to unowned properties voided so the object is uniformly owned. (These properties are set to a special "void" marker that throws a ReferenceVoid exception if you try to look at the property.)
    4. Because separation depends on an agent's ownership of objects, it is very important to an agent that travels or meets with other agents.
  8. Acquiring ownership of an object
    1. When one object creates a new object or copies an existing object, its owner is assigned to the new object. (This ensures that all of a process's objects create new objects that belong to the same process.)
  9. Transferring ownership of an object
    1. Using the "owned" keyword for argument passage transfers ownership of the argument from the requester to the responder.
    2. Ownership of a copied argument is always assigned to the responder's owner.
    3. When ownership of an object is transferred, the object's closure is transferred to the same ownership.
      1. If the object isn't uniformly owned before transfer, the engine throws ObjectUnowned.
      2. Protected objects may not change ownership.
      3. Locked objects may change ownership.
      4. Objects subclassed from Protected may change ownership.
  10. Isolating an object
    1. Isolating an object voids any references from inside the object's closure to objects outside that don't share the same owner. It also voids any references from outside the closure to objects inside, even if they share the same owner. The one exception: references to the isolated object itself aren't voided.
    2. To isolate an object, call "isolate" on the object.
    3. The partAll operation isolates the responding agent as part of the operation.
    4. Isolation is used before an agent travels. It's also used before an object is frozen (described later).
  11. Ownership during execution
    1. The current owner is the process under which an operation is executed. The current object is the responder (the object whose operation is executing).
    2. When an object of one owner calls an operation on an object of another owner, the operation is executed with the requester as the current owner.
    3. An own block (using the "own" keyword) executes with owner of the current object as the current owner.
      1. If the requester and responder are owned by different processes, the current owner changes to the owner of the current object during block execution, then reverts to the requester after execution.
      2. Because the effective permit used for execution is that of the current owner, changing ownership for a block can increase capabilities if the current object has a less restrictive permit than the requester. (Think of it as the opposite of a restrict block in this case.) It differs from a sponsored block because there is no authority involved.
      3. All objects created by the current owner are assigned ownership to that owner.
  12. Argument ownership

TS Ref - 26 JUN 1996

Generated by the sweat of Mike Boom's brow.