Next: TypeEq, Previous: Conversion, Up: Top
A language that permits user-defined types must provide constructs for the user to specify the properties of such types. If user-defined types can be named, then defining and applied occurrences of type identifiers must be recognized and checked for correct usage.
Here are some examples of user-defined types in Mystery:
TYPE Inches = INTEGER;
TYPE Length = Row;
TYPE Matrix = ARRAY [1 TO 10] OF Row;
TYPE Row = ARRAY [1 TO 10] OF Inches;
TYPE Column = ARRAY [1 TO 10] OF Inches;
TYPE Math = PROCEDURE (i: Inches, r: Row): Column;
This sequence of type declarations defines six type identifiers
(Inches, Length, Matrix, Row, Column,
and Math).
The second declaration states clearly that the identifiers Length
and Row name the same type, but the identifiers Row and
Column may or may not name the same type
(see Type equivalence).
Finally, the type [1 TO 10] is anonymous; it is not named by
any type identifier.
Computational roles to support user-defined types are provided by the
Typing module (see Typed Entities):
TypeDenotationType attribute is a new, unique, definition table key.
TypeDefDefIdChkTypeDefDefIdTypeDefUseIdChkTypeDefUseId