[comp.lang.modula2] MODULEs body

kloppen@gmdzi.UUCP (Jelske Kloppenburg) (03/22/89)

When I have a Module, that has to initialise itself, I write the
corresponding statements into the body of the module.
If at program end closing actions are neccessary, I have to do them
in the enclosing program. It woud be nice, to have them also in the
module. The syntax could be as in SIMULA classes. That would look
like this:

IMPLEMENTATION MODULE HandleSomeThing;
...

BEGIN
   OpenSomeThing;
   INNER;
   CloseThatThing
END HandleSomeThing.

Kloppenburg@kmx.gmd.dbp.de
kloppen@gmdzi.UUCP

randy@m2xenix.UUCP (Randy Bush) (03/25/89)

Almost all implementations of Modula-2 provide a library module which provides
a hook to register a termination procedure.  The simplest example might be:

DEFINITION MODULE Termination;

EXPORT QUALIFIED RegisterTermProc;

PROCEDURE RegisterTermProc ( p : PROC );
(* p will be called at program termintation, normal or abnormal.  if
   more than one p is registered, they will be called in lifo order *)

END Termination.
-- 
{ mcvax!uunet!oresoft, tektronix!percival!qiclab } !m2xenix!randy  Randy Bush

aplusl@ethz.UUCP (Albert Meier) (03/31/89)

In some M2 compilers it is possible to define TermProcedures that do the
job of terminating the modules action (even if the program breaks). In
the following 2 compilers you can even define an order/hierarchy for
these TermProcedures: M2Amiga and M2/370

    .....           Albert Meier        Tel.  +41/1/700 30 37
   .. ....          A+L AG, Im Spaeten 23, CH-8906 Bonstetten
  ..   ....
 .......A+L.        E-Mail          aplusl@ifi.ethz.(ch/UUCP)
..       .......                 ...mcvax!cernvax!ethz!aplusl