| | 1 | == Definition of terms: == |
| | 2 | |
| | 3 | C2Object:: Python object that owns both the shared attributes and the default per-instance attributes. |
| | 4 | |
| | 5 | Reference (n):: Python object created from a C2Object and inherits values for both types of attributes. A reference may have its own values for per-instance attributes but not for shared attributes. |
| | 6 | |
| | 7 | Reference (v):: Create a reference to an object. Referencing a reference is the same as referencing the underlying object. |
| | 8 | |
| | 9 | Replicate:: Copy a C2Object and all its attribute values. If the C2Object being replicated has shared attributes, the shared attributes of the new C2Object must not refer to the same underlying data. |
| | 10 | |
| | 11 | == Discussion: == |
| | 12 | |
| | 13 | References may be implemented either symmetrically or asymmetrically. |
| | 14 | |
| | 15 | A symmetric reference copies the per-instance attributes. The values from the original C2Object is copied during reference creation and never accessed again. A symmetric reference is a C2Object (always owns its per-instance attributes) and shares ownership of the shared attributes with the original C2Object. The original C2Object may be deleted without consequence. |
| | 16 | |
| | 17 | An asymmetric reference creates a proxy object that tracks the original C2Object. An asymmetric reference does not own the per-instance attributes but can override them with its own values. If a reference does not override an instance attribute, then the value of that attribute is fetched from the original C2Object at the time of access. Asymmetric references do not own and cannot directly modify shared attributes. The original C2Object must not be deleted until all references to it have been deleted. |