Common Lisp - Condition System

The condition system is responsible for exception handling in Common Lisp. It provides conditions, handlers and restarts. Conditions are objects describing an exceptional situation (for example an error). If a condition is signaled, the Common Lisp system searches for a handler for this condition type and calls the handler. The handler can now search for restarts and use one of these restarts to repair the current problem. As part of a user interface (for example of a debugger), these restarts can also be presented to the user, so that the user can select and invoke one of the available restarts. Since the condition handler is called in the context of the error (without unwinding the stack), full error recovery is possible in many cases, where other exception handling systems would have already terminated the current routine. The debugger itself can also be customized or replaced using the *DEBUGGER-HOOK* dynamic variable.

In the following example (using Symbolics Genera) the user tries to open a file in a Lisp function test called from the Read-Eval-Print-LOOP (REPL), when the file does not exist. The Lisp system presents four restarts. The user selects the Retry OPEN using a different pathname restart and enters a different pathname (lispm-init.lisp instead of lispm-int.lisp). The user code does not contain any error handling code. The whole error handling and restart code is provided by the Lisp system, which can handle and repair the error without terminating the user code.

Command: (test ">zippy>lispm-int.lisp") Error: The file was not found. For lispm:>zippy>lispm-int.lisp.newest LMFS:OPEN-LOCAL-LMFS-1 Arg 0: #P"lispm:>zippy>lispm-int.lisp.newest" s-A, : Retry OPEN of lispm:>zippy>lispm-int.lisp.newest s-B: Retry OPEN using a different pathname s-C, : Return to Lisp Top Level in a TELNET server s-D: Restart process TELNET terminal -> Retry OPEN using a different pathname Use what pathname instead : lispm:>zippy>lispm-init.lisp.newest ...the program continues

Read more about this topic:  Common Lisp

Famous quotes containing the words condition and/or system:

    No society has been able to abolish human sadness, no political system can deliver us from the pain of living, from our fear of death, our thirst for the absolute. It is the human condition that directs the social condition, not vice versa.
    Eugène Ionesco (b. 1912)

    Exploitation and oppression is not a matter of race. It is the system, the apparatus of world-wide brigandage called imperialism, which made the Powers behave the way they did. I have no illusions on this score, nor do I believe that any Asian nation or African nation, in the same state of dominance, and with the same system of colonial profit-amassing and plunder, would have behaved otherwise.
    Han Suyin (b. 1917)