Code: Select all
MODULE M1;
TYPE
T1* = POINTER TO T1Desc;
T1Desc* = RECORD
i: INTEGER
END;
PROCEDURE P1*(t: T1);
END P1;
PROCEDURE Init*(t: T1);
BEGIN
t.i := 13
END Init;
END M1.
Code: Select all
MODULE M2;
IMPORT M1;
TYPE
T2* = POINTER TO T2Desc;
T2Desc* = RECORD(M1.T1Desc)
j: INTEGER
END;
PROCEDURE P2*(t: T2);
BEGIN
t.i := 4 (*problem*)
END P2;
PROCEDURE Init*(t: T2);
BEGIN
t.j := 17
END Init;
END M2.
If I put all the code into one module...
Code: Select all
MODULE M3;
TYPE
T1* = POINTER TO T1Desc;
T1Desc* = RECORD
i: INTEGER
END;
T2* = POINTER TO T2Desc;
T2Desc* = RECORD(T1Desc)
j: INTEGER
END;
PROCEDURE P1*(t: T1);
END P1;
PROCEDURE P2*(t: T2);
BEGIN
t.i := 4
END P2;
PROCEDURE InitT1*(t: T1);
BEGIN
t.i := 13
END InitT1;
PROCEDURE InitT2*(t: T2);
BEGIN
t.j := 17
END InitT2;
END M3.
To me, 1) this does not seem consistent, and, 2) in the case of the separated modules, is a real limitation. The author of a module should not need to "prepare" possible future extensions, aside from the problems with exporting implementation details of a type.
Is this a limitation of the language or the compiler? Or do I miss something here?
(FWIW, the practical use case here is a serial USART module that I want to extend with a data transmission functionality using a buffer and interrupt-driven sending.)