[Oberon] Module aliases - what is the correct way to handle them

Andreas Pirklbauer andreas_pirklbauer at yahoo.com
Sun Feb 9 19:28:08 CET 2020


ADDENDUM: Accidentally posted an old set of modules. Below is the current
one from http://github.com/andreaspirklbauer/Oberon-test-module-aliases

Any input is welcome!  Current favourite is ORB6.Mod .

-ap



———————————————————————————————————————————————



ORB0.Mod (= current FPGA Oberon version; only tests obj.name against name)

     obj1 := topScope; obj := obj1.next;  (*search for module*)
     WHILE (obj # NIL) & (obj.name # name) DO obj1 := obj; obj := obj1.next END ;

ORB1.Mod (tests obj.name against name and obj.orgname against orgname separately)

     obj1 := topScope; obj := obj1.next;  (*search for module*)
     WHILE (obj # NIL) & (obj.name # name) DO obj1 := obj; obj := obj1.next END ;
     IF obj = NIL THEN 
       obj1 := topScope; obj := obj1.next;
       WHILE (obj # NIL) & (obj IS Module) & (obj(Module).orgname # orgname) DO
         obj1 := obj; obj := obj1.next
       END
     END ;

ORB2.Mod (tests obj.name against name and obj.orgname against orgname in a single loop)

     obj1 := topScope; obj := obj1.next;  (*search for module*)
     WHILE (obj # NIL) & (obj IS Module) & (obj.name # name) & (obj(Module).orgname # orgname) DO
       obj1 := obj; obj := obj1.next
     END ;

ORB3.Mod (tests only obj.orgname against orgname)

     obj1 := topScope; obj := obj1.next;  (*search for module*)
     WHILE (obj # NIL) & (obj IS Module) & (obj(Module).orgname # orgname) DO
       obj1 := obj; obj := obj1.next
     END ;

ORB4.Mod (tests obj.orgname against name)

     obj1 := topScope; obj := obj1.next;  (*search for module*)
     WHILE (obj # NIL) & (obj IS Module) & (obj(Module).orgname # name) DO
       obj1 := obj; obj := obj1.next
     END ;

ORB5.Mod (tests all possible combinations EXCEPT obj.orgname against name)

     obj1 := topScope; obj := obj1.next;  (*search for module*)
     WHILE (obj # NIL) & (obj IS Module) & (obj.name # name) & (obj.name # orgname) &
         (obj(Module).orgname # orgname) DO
       obj1 := obj; obj := obj1.next
     END ;

ORB6.Mod (tests all possible combinations of obj.orgname and obj.name against orgname and name)

     obj1 := topScope; obj := obj1.next;  (*search for module*)
     WHILE (obj # NIL) & (obj IS Module) & (obj.name # name) & (obj.name # orgname) &
         (obj(Module).orgname # orgname) & (obj(Module).orgname # name) DO
       obj1 := obj; obj := obj1.next
     END ;

M.Mod
————

MODULE X; TYPE T* = RECORD END ; END X.

MODULE M0;
  TYPE T0* = RECORD i: INTEGER END ;
END M0.

MODULE M1;
  IMPORT M0;
  TYPE T1* = RECORD (M0.T0) j: INTEGER END ;
END M1.

MODULE M2;
  IMPORT M1;
  TYPE T2* = RECORD (M1.T1) k: INTEGER END ;  (*indirectly imports M0.T0*)
END M2.

MODULE M3;
  IMPORT X := M0, M2, X;
  TYPE T3* = RECORD (M2.T2) k: INTEGER END ;  (*indirectly imports M1.T1 and M0.T0*)
END M3.

MODULE M4;
  IMPORT Y := M0, M0;   (*importing a module M0 under two different names is never allowed*)
END M4.

MODULE M5;
  IMPORT Z := M0, M0 := M1;     (*ORB4 allows M0 := M1, while ORB5 disallows it*)
END M5.

————————————————————————————————————————————————

ORP.Compile @/s ~    # compile the above module sequence with several different versions of ORB

ORP.Compile ORB0.Mod/s ~   System.Free ORP ORG ORB ~   now recompile M3, M4, M5

-> catches the "invalid import order" error in M3
-> catches the "invalid import order" error in M4
-> does not catch an "invalid import order" error in M5

ORP.Compile ORB1.Mod/s ~   System.Free ORP ORG ORB ~   now recompile M3, M4, M5

-> catches the "invalid import order" error in M3
-> catches the "invalid import order" error in M4
-> does not catch an "invalid import order" error in M5

ORP.Compile ORB2.Mod/s ~   System.Free ORP ORG ORB ~   now recompile M3, M4, M5

-> catches the "invalid import order" error in M3
-> catches the "invalid import order" error in M4
-> does not catch an "invalid import order" error in M5

ORP.Compile ORB3.Mod/s ~   System.Free ORP ORG ORB ~   now recompile M3, M4, M5

-> does NOT catch the "invalid import order" error in M3
-> catches the "invalid import order" error in M4
-> does not catch an "invalid import order" error in M5

ORP.Compile ORB4.Mod/s ~   System.Free ORP ORG ORB ~   now recompile M3, M4, M5

-> does NOT catch the "invalid import order" error in M3
-> catches the "invalid import order" error in M4
-> catches the "invalid import order" error in M5

ORP.Compile ORB5.Mod/s ~   System.Free ORP ORG ORB ~   now recompile M3, M4, M5

-> catches the "invalid import order" error in M3
-> catches the "invalid import order" error in M4
-> does not catch an "invalid import order" error in M5

ORP.Compile ORB6.Mod/s ~   System.Free ORP ORG ORB ~   now recompile M3, M4, M5

-> catches the "invalid import order" error in M3
-> catches the "invalid import order" error in M4
-> catches the "invalid import order" error in M5    # error message intentional here!


More information about the Oberon mailing list