[Oberon] Type compatibility rules for Pointers

Tomas Kral thomas.kral at email.cz
Tue Jun 16 09:08:22 CEST 2020


On Mon, 15 Jun 2020 21:43:48 +0200
August Karlstrom <fusionfile at gmail.com> wrote:

> 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.

Oberon-07 allows [no only] array assignments, SYSTEM.COPY() not needed
in many situations. 

I found this even more interesting..

MODULE Types; (*type compatibility*)
  TYPE
    P1 = POINTER TO R1;
    P2 = POINTER TO R2;

    R1 = RECORD END;
    R2 = RECORD (R1) END;

   PROCEDURE Test*;
     VAR p1: P1; p2: P2;
   BEGIN NEW(p1); NEW(p2);

     (*possible*)
     IF p1 IS p2 THEN (*true*) END ;
     p1 := p2;

     (*not possible*)
     IF p2 IS p1 THEN (*true*) END ;
     p2 := p1;

   END Test;
END Types.Test

-- 
Tomas Kral <thomas.kral at email.cz>


More information about the Oberon mailing list