Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Common Lisp
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Condition system== The ''condition system'' is responsible for [[exception handling]] in Common Lisp.<ref name="Seibel2005">{{cite book|author=Peter Seibel|title=Practical Common Lisp|url=http://www.gigamonkeys.com/book/beyond-exception-handling-conditions-and-restarts.html|date=April 7, 2005|publisher=Apress|isbn=978-1-59059-239-7}}</ref> It provides ''conditions'', ''handler''s and ''restart''s. ''Condition''s 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 automatically repair the current problem, using information such as the condition type and any relevant information provided as part of the condition object, and call the appropriate restart function. These restarts, if unhandled by code, can be presented to users (as part of a user interface, that of a debugger for example), 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 <code>*debugger-hook*</code> dynamic variable. Code found within ''unwind-protect'' forms such as finalizers will also be executed as appropriate despite the exception. 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. <syntaxhighlight lang="text"> 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, <Resume>: Retry OPEN of lispm:>zippy>lispm-int.lisp.newest s-B: Retry OPEN using a different pathname s-C, <Abort>: 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 [default lispm:>zippy>lispm-int.lisp.newest]: lispm:>zippy>lispm-init.lisp.newest ...the program continues </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)