Type Compatibility [ HP Pascal/iX Reference Manual ] MPE/iX 5.0 Documentation
HP Pascal/iX Reference Manual
Type Compatibility
Relative to each other, two HP Pascal types can be identical, type
compatible, or incompatible. The guidelines that determine type
compatibility are listed below.
Identical Types
Two types are identical if either of the following is true:
* Their types have the same type identifier.
* If A and B are two type identifiers, and they were made equivalent
by a definition of the form:
TYPE A = B
Compatible Types
Two types, T1 and T2, are type compatible if any of the following is
true:.
* T1 and T2 are identical types.
* T1 and T2 are subranges of identical base types, T1 is a subrange
of T2, or T2 is a subrange of T1.
* T1 and T2 are set types with compatible base types and both T1 and
T2 or neither are packed or crunched.
* T1 and T2 are PAC types.
* T1 and T2 are both string types.
* T1 and T2 are both real types.
Incompatible Types
Two types are incompatible if they are not identical or type compatible,
or assignment compatible. In the following example all of the variables
are type compatible, but v4, v5, and v6 have identical types. The
variables v2 and v3 also have identical types.
Example
TYPE
interval = 0..10;
range = interval;
VAR
v1 : 0..10;
v2, v3: 0..10;
v4 : interval;
v5 : interval;
v6 : range;
Note that two types that are structurally the same are not necessarily
compatible. In the following example, types T1 and T2 are not
compatible. Variables v3 and v4 are also not compatible.
PROGRAM t(input,output);
TYPE
T1 = record
a: integer;
b: char;
end;
T2 = record
c: integer;
d: char;
end;
VAR
v1: T1;
v2: T2;
v3: ^T1;
v4: ^T2;
BEGIN
v1:= v2; { This generates a compile-time error }
v3:= v4; { This generates a compile-time error }
END.
MPE/iX 5.0 Documentation