Termination.mesa
Copyright Ó 1990, 1991, 1992 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, July 3, 1990 11:30 am PDT
Willie-s, March 5, 1992 3:54 pm PST
Simple termination control, serving two purposes.
1) Terminate world with a user message. E.g. On start-up failure.
2) Callback on termination. E.g. To return system resources claimed by start up.
DIRECTORY
Rope USING [ROPE];
Termination: CEDAR DEFINITIONS
~ BEGIN
QuitWorld: PROC [userMsg: Rope.ROPE ¬ NIL, interceptable: BOOL ¬ FALSE];
Quits from this world. Use interceptable = FALSE if caller thinks this to be a normal exit where debugging is not appropriate. Use interceptable = TRUE when something went wrong so badly that there is no point in continuing. If interceptable = TRUE and and the system is in debugging mode, the procedure simply raises the error quitWorld. In all other cases the registered before-quit-world procedures are called in reversed order, userMsg is typed, and the world is terminated.
quitWorld: ERROR [msg: Rope.ROPE];
CallBeforeQuitWorld: PROC [proc: PROC[REF], data: REF ¬ NIL];
Registers proc to be called before QuitWorld finally exits. Procedures are not called when an error is raised but only before final exit world. Procedures must not prevent quitting the world, since a procedure called just before might already have done irreversible damage. Clients please consider that the registered procedure might be called from a debugger.
Clients should note that their procs will NOT get called if the world is exited by other means than a call to Termination.QuitWorld.
SetDebuggingMode: PROC [];
From now on QuitWorld with interceptable=TRUE will not quit the world but raise the error quitWorld to enable debugging.
debuggingMode: READONLY BOOL;
END.