Previous | Table of Contents | Next |
A declaration of a packed type has the form
TYPE T = BITS n FOR Base
where Base is a type and n is an integer-valued constant expression. The values of type T are the same as the values of type Base, but variables of type T that occur in records, objects, or arrays will occupy exactly n bits and be packed adjacent to the preceding field or element. For example, a variable of type
ARRAY [0..255] OF BITS 1 FOR BOOLEAN
is an array of 256 booleans, each of which occupies one bit of storage.
The values allowed for n are implementation dependent. An illegal value for n is a static error. The legality of a packed type can depend on its context; for example, an implementation could prohibit packed integers from spanning word boundaries.
A set is a collection of values taken from some ordinal type. A set type declaration has the form
TYPE T = SET OF Base
where Base is an ordinal type. The values of T are all sets whose elements have type Base. For example, a variable whose type is SET OF [0..1] can assume the following values:
{} {0} {1} {0,1}
Implementations are expected to use the same representation for a SET OF T as for an ARRAY T OF BITS 1 FOR BOOLEAN. Hence, programmers should expect SET OF [0..1023] to be practical, but not SET OF INTEGER.
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 Type
where Type is any type. The values of T are traced references to variables of type Type, which is called the referent type of T.
A declaration for an untraced reference type has the form
TYPE T = UNTRACED REF Type
where Type is any untraced type. (This restriction is lifted in unsafe modules.) The values of T are the untraced references to variables of type 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. If 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:
REFANY | Contains all traced references | |
ADDRESS | Contains all untraced references | |
NULL | Contains only NIL |
The TYPECASE statement can be used to test the referent type of a REFANY or object, but there is no such test for an ADDRESS. 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;
A procedure is either NIL or a triple consisting of
A procedure that returns a result is called a function procedure; a procedure that does not return a result is called a proper procedure. A top-level procedure is a procedure declared in the outermost scope of a module. Any other procedure is a local procedure. A local procedure can be passed as a parameter but not assigned because in a stack implementation, a local procedure becomes invalid when the frame for the procedure containing it is popped.
A procedure constant is an identifier declared as a procedure (as opposed to a procedure variable, which is a variable declared with a procedure type).
A procedure type declaration has the form
TYPE T = PROCEDURE sig
where sig is a signature specification, which has the form
(formal1; ...; formaln): R RAISES S
A formal parameter declaration has the form
Mode Name: Type := Default
Previous | Table of Contents | Next |