148 lines
76 KiB
Plaintext
148 lines
76 KiB
Plaintext
1
|
||
|
||
LISP RELEASE NOTES, MEDLEY RELEASE, ERROR SYSTEM
|
||
1
|
||
|
||
LISP RELEASE NOTES, MEDLEY RELEASE, ERROR SYSTEM
|
||
APPENDIX E - ERROR SYSTEM
|
||
1
|
||
|
||
APPENDIX E - ERROR SYSTEM
|
||
1
|
||
|
||
|
||
|
||
|
||
APPENDIX E. ERROR SYSTEM
|
||
6
|
||
|
||
|
||
|
||
This appendix replaces Chapter 24, Error System, of Common Lisp Implementation Notes, Lyric Release, which replaced most of Chapter 24, Errors, of Common Lisp, the Language. Text shown with StrikeThru is that text from the Lyric release that no longer applies in Medley. Enhancements added in Medley are indicated with revision bars in the right margin.
|
||
The XCL error system has been updated to reflect the current ANSI Common Lisp error system proposal. This version seems to be gaining wide use in other Common Lisp implementations, so no further major changes are anticipated.
|
||
The Common Lisp error system is based on proposal number 18 for the Common Lisp error system. Deviations from this proposal are noted. Since the Common Lisp error system has not yet been standardized, this system may change in future releases to accommodate the final version of the Common Lisp error system.
|
||
If you have access to the ARPANet, a copy of this (ERROR% SYSTEM% PROPOSAL NIL Error% system% proposal NIL (E) 1)proposal may be retrieved from MIT-AI.ARPA as the file "COMMON;COND18 TXT".
|
||
All symbols(SYMBOLS NIL Symbols NIL (E) 1 SUBNAME IN% ERROR% SYSTEM% SUBTEXT in% Error% system% ) described in the error system proposal that are not already in the "LISP" package are exported from the "CONDITIONS" package. In addition, the "XEROX-COMMON-LISP" package exports these symbols, so you can make them available either by using "XCL" or using "CONDITIONS", whichever is appropriate to your application. The distinction is made so that XCL extensions of the Common Lisp error system will be clear. All unqualified symbols are assumed to be in the "LISP" package.
|
||
2
|
||
|
||
Summary of Error System Changes
|
||
1
|
||
|
||
|
||
The semantics of HANDLER-BIND where multiple bindings are set up or mutiple condition types are being handled are slightly (ERROR% SYSTEM% NIL Error% system NIL (E) 1 SUBNAME DIFFERENCES% BETWEEN% OLD% AND% NEW% % SUBTEXT differences% between% old% and% new% )different. Old code that used this will probably not behave as expected.
|
||
HANDLER-BIND and HANDLER-CASE (a.k.a. CONDITION-CASE) now always take a typespec instead of a list of condition types to indicate the conditions to be handled. Old code that uses this will only handle the first condition type in the list. The function, CONDITIONS::CONVERT-HANDLER-CASE is provided to aid in converting old code(CONVERTING% OLD% CODE NIL Converting% old% code NIL (E) 1 SUBNAME FOR% USE% WITH% NEW% ERROR% SYSTEM% SUBTEXT for% use% with% new% Error% system% ). It may be used as a mutation function in SEdit.
|
||
HANDLER-CASE now supports a :NO-ERROR option that is executed if none of the other clauses are taken. This is handy for writing code that depends on the normal completion of some operation, for example, creating auxilliary files if a particular stream is successfully opened.
|
||
SERIOUS-CONDITION no longer forces entry to the debugger. The function used to signal the condition now determines what happens if the condition is not handled. This means that SERIOUS-CONDITION has no more interesting properties and is likely to be removed in the final version of the error standard.
|
||
Several new condition types have been defined. Others have moved in the hierarchy. For example, ILLEGAL-GO is now a subtype of PROGRAM-ERROR.
|
||
No standard condition type has a default handler.
|
||
The standard debugger entry point is now called INVOKE-DEBUGGER instead of DEBUG.
|
||
The syntax of DEFINE-CONDITION has been changed to make it more like CLOS' DEFCLASS. The function CONDITIONS::CONVERT-OLD-DEFINE-CONDITION is provided to aid in converting old code. It may be used as a mutation function in SEdit.
|
||
Several DEFINE-CONDITION options have been merged, while others have been removed. In particular, there are no more "instant variables."
|
||
PROCEED-CASE has been replaced by RESTART-CASE. The semantics of restarts have been cleaned up and several new features added. Related functions, such as COMPUTE-PROCEED-CASES, have been renamed appropriately.
|
||
INVOKE-PROCEED-CASE has been renamed to INVOKE-RESTART.
|
||
DEFINE-PROCEED-FUNCTION has been removed, although XCL will continue to support it for compatibility.
|
||
The arguments to a restart's report function are different. Old code that used something other than a string for the report method will not work correctly.
|
||
A distinction is now made between invoking a restart interactively and simply invoking one. To this end, there is the function INVOKE-RESTART-INTERACTIVELY and the :INTERACTIVE option to RESTART-CASE.
|
||
RESTART-BIND, in analogy to HANDLER-BIND, has been added.
|
||
A new variable, *BREAK-ON-SIGNALS* exists to aid in debugging. It is a generalization of *BREAK-ON-WARNINGS*. The latter has been retained for compatibility.
|
||
The proceed function PROCEED has been changed to CONTINUE.
|
||
Old compiled code will continue to work except in the following cases, some of which have been mentioned above:
|
||
A proceed case's report function was not a simple string. Such code can cause stack overflow trying to report the condition (*STANDARD-OUTPUT* ends up being bound to NIL). Such code should be rewritten.
|
||
A handler binding is made to a list of condition types. Only the first type in the list will be handled.
|
||
Multiple handler bindings were created by the same HANDLER-BIND or HANDLER-CASE. Such code will work as expected, but if recompiled in Medley, will not. To get the effect of the current semantics, you must use nested HANDLER-BINDs.
|
||
Under the new error system, use-value and store-value no longer prompt for a value.
|
||
2
|
||
|
||
Introduction to Error System Terminology
|
||
1
|
||
|
||
|
||
(CONDITION NIL condition NIL (E) 3)condition A condition is a kind of object which is created when an exceptional situation arises in order to represent the relevant features of that situation.
|
||
(SIGNALLING% CONDITIONS NIL Signalling% conditions NIL (E) 3)signal, (HANDLING% CONDITIONS% NIL Handling% conditions% NIL (E) 3)handlers Once a condition is created, it is common to signal it. When a condition is signaled, a set of handlers are tried in some pre-defined order until one decides to handle the condition or until no more handlers are found. A condition is said to have been handled if a handler performs a non-local transfer of control to exit the signalling process.
|
||
(RESTARTING% COMPUTATIONS NIL Restarting% computations NIL (E) 3)restart Although such transfers of control may be done directly using traditional Lisp mechanisms such as catch and throw, block and return, or tagbody and go, the condition system also provides a more structured way to restart a computation. Among other things, the use of these structured primitives for restarting allows a better and more integrated relationship between the user program and the interactive debugger.
|
||
serious conditions It is not necessary that all conditions be handled. Some conditions are trivial enough that a failure to handle them may be disregarded. Others, which we will call serious conditions must be handled in order to assure correct program behavior. If a serious condition is signalled but no handler is found, the debugger will be entered so that the user may interactively specify how to proceed.
|
||
errors(ERRORS NIL Errors NIL (E) 3 SUBNAME DEFINITION% OF% SUBTEXT definition% of% ) conditions which result from incorrect programs or data are called errors. Not all conditions are errors, however. Storage conditions are examples of conditions that are not errors. For example, the control stack may legitimately overflow without a program being in error. Even though a stack overflow is not necessarily a program error, it is serious enough to warrant entry to the debugger if the condition goes unhandled.
|
||
Some types of conditions are predefined by the system. All types of conditions are subtypes of conditions:condition. That is,
|
||
(typep c 'conditions:condition)
|
||
is true if c is a condition.
|
||
creating conditions(CREATING% CONDITIONS NIL Creating% conditions NIL (E) 4) The only standard way to define a new condition type is conditions:define-condition. The only standard way to instantiate a condition is conditions:make-condition.
|
||
When a condition object is created, the most common operation to be performed upon it is to signal it (although there may be applications in which this does not happen, or does not happen immediately).
|
||
When a condition is signaled, the system tries to locate the most appropriate handler for the condition and invoke that handler. Handlers are located according to the following rules:
|
||
(BOUND% NIL bound% NIL (E) 4)bound <09><> |