# Types

> I am the voice of today, the herald of tomorrow... I am the leaden army that conquers the world---I am TYPE. ---Frederic William Goudy

Modula-3 uses structural equivalence, instead of the name equivalence of Modula-2. Two types are the same if their definitions become the same when expanded; that is, when all constant expressions are replaced by their values and all type names are replaced by their definitions. In the case of recursive types, the expansion is the infinite limit of the partial expansions. A type expression is generally allowed wherever a type is required.

A type is empty if it contains no values. For example, `[1..0]` is an empty type. Empty types can be used to build non-empty types (for example, `SET OF [1..0]`, which is not empty because it contains the empty set). It is a static error to declare a variable of an empty type.

Every expression has a statically-determined type, which contains every value that the expression can produce. The type of a designator is the type of the variable it produces.

Assignability and type compatibility are defined in terms of a single syntactically specified subtype relation with the property that if `T` is a subtype of `U`, then every member of `T` is a member of `U`. The subtype relation is reflexive and transitive.

Every expression has a unique type, but a value can be a member of many types. For example, the value `6` is a member of both `[0..9]` and `INTEGER`. It would be ambiguous to talk about "the type of a value". Thus the phrase "type of `x`" means "type of the expression `x`", while "`x` is a member of `T`" means "the value of `x` is a member of `T`".

However, there is one sense in which a value can be said to have a type: every object or traced reference value includes a code for a type, called the allocated type of the reference value. The allocated type is tested by `TYPECASE`.

The type constructors and subtyping rules are discussed below

- Ordinal types
- Floating-point types
- Array types
- Record types
- Packed types
- Set types
- Reference types
- Procedure types
- Object types
- Subtyping rules
- Predeclared opaque types

    Last modified on Wed Apr  3 09:38:54 PST 1996 by heydon
         modified on Thu Apr 14 15:43:24 PDT 1994 by kalsow