[Oberon] Module finalization - language construct or system call

Andreas Pirklbauer andreas_pirklbauer at yahoo.com
Mon Jan 4 15:50:21 CET 2021


I would like to solicit input on whether to realize “module finalization”
via a CLOSE language construct or via a system call such as
Modules.Close. See the test module M below.  Both are currently
available in Extended Oberon, both are trivial to implement (only
a few lines each), but the question is what one *should* offer.

Some arguments in favour or against these 2 options include:

1) CLOSE as a language construct:

- A entire language construct for a (probably) rarely used feature
- Creates another dialect of Oberon-07, limiting portability of programs
+ clean solution
+ one does not need to import module Modules
+ Ease of porting for Component Pascal modules

2) Modules.Close as a system call:

+ no need for a separate language construct
+ sufficient for the (rare) cases where it is used
- need to add Modules.Close in all systems if one wants portability
- one has to import module Modules


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

1) CLOSE as a language construct:

MODULE M;
  IMPORT Texts, Oberon;
  VAR W: Texts.Writer;

  PROCEDURE Start*; BEGIN END Start;  (*load module*)

BEGIN  (*module initialization sequence*)
  Texts.OpenWriter(W)
CLOSE  (*module finalization sequence*)
  Texts.WriteString(W, "Finalizing module M…"); Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf)
END M.

ORP.Compile M.Mod/s ~     # compile module M
M.Start ~                              # load module M
System.Free M ~                 # unload module M (prints "Finalizing module M…”)

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

2) Modules.Close as a system call:

MODULE M;
  IMPORT Modules, Texts, Oberon;
  VAR W: Texts.Writer;

  PROCEDURE Close;
  BEGIN Texts.WriteString(W, "Finalizing module M…");
    Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf)
  END Close;

  PROCEDURE Start*; BEGIN END Start;  (*load module*)
 
BEGIN Texts.OpenWriter(W). Modules.Close(Close)
END M.

ORP.Compile M.Mod/s ~     # compile module M
M.Start ~                              # load module M
System.Free M ~                 # unload module M (prints "Finalizing module M…")





More information about the Oberon mailing list