An object reference may be a constant or variable reference to an object.
Constant reference
A constant reference declaration has the form:
name: obj ObjectDescriptor
where name the name of the object and ObjectDescriptor is a description of the object being referred to. The ObjectDescriptor is executed when the data-item is generated as part of the generation of the enclosing object.
An object described by an ObjectDescriptor where the items-part is non-empty – i.e. n >= 1, is called a singular object.
Examples
O1: obj Record
O2: obj Person("John Smith",21)
O3: obj Record
id: var integer
owner: ref Person
O1
, O2
, and O3
are constant objects. O3
is a singular object.
Variable reference
A variable reference declaration has the form:
name: ref object-pattern-name
where name
is the name of a reference to an object as described by object-pattern-name
, which is the name of a pattern. name
may refer different objects during the lifetime of the enclosing object. name
is initially none
, which means that it does not refer to any object.
Examples
V4: ref Record -- initial value is none
V5: ref Person -- ditto
V4
nd V5
are both variables references.