[Oberon] Type compatibility rules for Pointers
chris at gcjd.org
Mon Jun 15 21:09:40 CEST 2020
please look at the following example:
R = RECORD i : INTEGER END;
P1 = POINTER TO R;
P2 = POINTER TO R;
p1 : P1; p2 : P2;
IF p1 IS P2 THEN (* true *) END;
p1 := p2;
The dynamic type test is not a surprise as the type tag refers to the
same record descriptor although I think it's a bit counter intuitive.
I am a bit confused that p1 := p2 compiles without errors. The
Oberon-07 report says:
"The type of the expression must be the same as that of the designator"
and gives a list of 4 exceptions. Here only number 3 is of interest:
"3. In the case of records, the type of the source must be an extension
of the type of the destination."
But in my understanding pointers are not records and P1 and P2 are
More information about the Oberon