[Oberon] Module finalization - language construct or system call

Joerg joerg.straube at iaeth.ch
Mon Jan 4 16:02:19 CET 2021


Perhaps I might add a third question: Who of you needs this feature in a productive environment knowing that batch command execution exists where a sequence of calls to closing functions can be automated?
Jörg

Am 04.01.21, 15:50 schrieb "Oberon im Auftrag von Andreas Pirklbauer" <oberon-bounces at lists.inf.ethz.ch im Auftrag von andreas_pirklbauer at yahoo.com>:

    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…")



    --
    Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
    https://lists.inf.ethz.ch/mailman/listinfo/oberon




More information about the Oberon mailing list