A reference value is either
NIL or the address of a variable,
called the referent.
A reference type is either traced or untraced. When all traced references to a piece of allocated storage are gone, the implementation reclaims the storage. Two reference types are of the same reference class if they are both traced or both untraced. A general type is traced if it is a traced reference type, a record type any of whose field types is traced, an array type whose element type is traced, or a packed type whose underlying unpacked type is traced.
A declaration for a traced reference type has the form:
TYPE T = REF Typewhere
Typeis any type. The values of
Tare traced references to variables of type
Type, which is called the referent type of
A declaration for an untraced reference type has the form:
TYPE T = UNTRACED REF Typewhere
Typeis any untraced type. (This restriction is lifted in unsafe modules.) The values of
Tare the untraced references to variables of type
In both the traced and untraced cases, the keyword
REF can optionally
be preceded by ``
BRANDED b'' where
b is a text constant called
the brand. Brands distinguish types that would otherwise be the same;
they have no other semantic effect. All brands in a program must be distinct.
BRANDED is present and
b is absent, the implementation
automatically supplies a unique value for
b. Explicit brands are
useful for persistent data storage.
The following reference types are predeclared:
Contains all traced references
Contains all untraced references
TYPECASEstatement can be used to test the referent type of a
REFANYor object, but there is no such test for an
Examples of reference types:
TYPE TextLine = REF ARRAY OF CHAR; ControllerHandle = UNTRACED REF RECORD status: BITS 8 FOR [0..255]; filler: BITS 12 FOR [0..0]; pc: BITS 12 FOR [0..4095] END; T = BRANDED "ANSI-M3-040776" REF INTEGER; Apple = BRANDED REF INTEGER; Orange = BRANDED REF INTEGER;