Article View: comp.lang.modula2
Article #4307Re: Termination of program
From: Gernot Heiser
Date: Sun, 03 Jul 1988 17:14
Date: Sun, 03 Jul 1988 17:14
57 lines
2713 bytes
2713 bytes
In article <492@ethz.UUCP> aplusl@ethz.UUCP (Albert Meier) writes:
}Although an IMPLEMENTATION MODULE makes provision for "hidden"
}initialisation code in Modula-2 programs, there is no simple
}standardised way of providing termination code. In UCSD Pascal,
}and in Pascal-Plus this could be done as follows
}
}
} BEGIN (*main code of unit, envelope or whatever*)
} Initialise;
} ***;
} Terminate
} END.
}
}Here the *** essentially stands for "execute all the code of the
}client".
This corresponds to the way it is done in SIMULA-67: a class initialization
part may contain an "INNER" statement; everything after the INNER statement
wasn't executed until later (`later' depending on the usage of the class).
}...
}One could not introduce exactly the same effect into Modula-2
}without a syntactic change of a fairly radical nature. However,
}one could achieve a useful compromise on the lines of the
}following:
}...
} IMPLEMENTATION MODULE Gizmo;
}
} IMPORT Somewhere;
}
} PROCEDURE CleanUp;
} BEGIN
} (* Termination code *)
} END CleanUp;
}
} (* rest of module *)
}
} BEGIN (*Gizmo*)
} Initialise;
} Somewhere.TERMINATE(CleanUp)
} END Gizmo.
}
}... One
}important point is that the routines linked in this way should be
}called (so far as possible) no matter how a program terminates.
Sorry, I don't see that. Why should the termination part be something
fundamentally different from the initialization part? The latter is not
executed if some statement in an earlier initialized module's initialization
part causes program termination. In general, continuation makes no sense after
a run time error, unless real exceptions are introduced (which, in particular,
should allow the program to somehow determine the reason of the termination).
--
Gernot Heiser <heiser@iis.UUCP> Phone: +41 1/256 23 48
Integrated Systems Laboratory CSNET/ARPA: heiser%ifi.ethz.ch@relay.cs.net
ETH Zuerich EARN/BITNET: GRIDFILE@CZHETH5A
CH-8092 Zuerich, Switzerland EUNET/UUCP: {uunet,mcvax,...}!iis!heiser
Technical Details
Message-ID:
<493@ethz.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!ubvax!lll-winken!uunet!mcvax!cernvax!ethz!heiserReferences:
<492@ethz.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!ubvax!lll-winken!uunet!mcvax!cernvax!ethz!heiser From: heiser@ethz.UUCP (Gernot Heiser) Newsgroups: comp.lang.modula2 Subject: Re: Termination of program Message-ID: <493@ethz.UUCP> Date: 3 Jul 88 17:14:07 GMT References: <492@ethz.UUCP> Reply-To: heiser@iis.UUCP (Gernot Heiser) Organization: ETH Zuerich, Switzerland Lines: 56