[Oberon] Type compatibility rules for Pointers
August Karlstrom
fusionfile at gmail.com
Mon Jun 15 21:43:48 CEST 2020
On 2020-06-15 21:09, chris wrote:
> TYPE
> R = RECORD i : INTEGER END;
> P1 = POINTER TO R;
> P2 = POINTER TO R;
>
> PROCEDURE Test();
> VAR
> p1 : P1; p2 : P2;
> BEGIN
> NEW(p1); NEW(p2);
> IF p1 IS P2 THEN (* true *) END;
> p1 := p2;
> END Test;
[...]
> I am a bit confused that p1 := p2 compiles without errors.
Section 6.4 in the language report says that "Pointer types inherit the
extension relation of their base types, if there is any." Also P2 is a
(trivial) extension of P1 and vice versa.
August
More information about the Oberon
mailing list