Type Compatibility and Identity To understand which operations can be performed on which expressions, we need to distinguish several kinds of
compatibility among types and values. These include:
Type identity
Type compatibility
Assignment compatibility
Type Identity When one type identifier is declared using another type identifier, without qualification, they denote the same type.
Thus, given the declarations
type
T1 = Integer;
T2 = T1;
T3 = Integer;
T4 = T2;
T1
,
T2
,
T3
,
T4
, and Integer all denote the same type. To create distinct types, repeat the word type in the declaration.
For example,
type TMyInteger = type Integer;
creates a new type called
TMyInteger
which is not identical to Integer.
Language constructions that function as type names denote a different type each time they occur. Thus the
declarations
type
TS1 = set of Char;
TS2 = set of Char;
create two distinct types,
TS1
and
TS2
. Similarly, the variable declarations
var
S1: string[10];
S2: string[10];
create two variables of distinct types. To create variables of the same type, use
var S1, S2: string[10];
or
type MyString = string[10];
var
97