Common Lisp the Language, 2nd Edition

Next: Introduction Up: Common Lisp the Language Previous: Functions in the

# 29. Conditions

By Kent M. Pitman

`PREFACE:` The language defined by the first edition contained an enormous lacuna: although facilities were specified for signaling errors, no means was defined for handling errors. This occurred not through neglect of the issue, but because this part of the Lisp language generally was in a state of flux. There were several proposals at the time. The committee, finding that it could not agree on any one proposal, agreed to disagree and omit error handling from Common Lisp for the time being. This defect has now been addressed.

X3J13 voted in June 1988 (CONDITION-SYSTEM) to adopt the Common Lisp Condition System as a part of the forthcoming draft Common Lisp standard. X3J13 voted in March 1989 (ZLOS-CONDITIONS) to amend the specification of conditions to integrate them with the Common Lisp Object System (see chapter 28). X3J13 voted in June 1989 (CONDITION-RESTARTS) to amend the specification of restarts in certain ways. These amendments have been incorporated here with little further comment.

This chapter presents the bulk of the Common Lisp Condition System proposal, written by Kent M. Pitman and amended by X3J13. I have edited it only very lightly to conform to the overall style of this book and have inserted a small number of bracketed remarks identified by the initials GLS. Please see the Acknowledgments to this second edition for the author's acknowledgments to others who contributed to the Condition System proposal.

> -Guy L. Steele Jr.

- Introduction
- Changes in Terminology
- Survey of Concepts
  - Signaling Errors
  - Trapping Errors
  - Handling Conditions
  - Object-Oriented Basis of Condition Handling
  - Restarts
  - Anonymous Restarts
  - Named Restarts
  - Restart Functions
  - Comparison of Restarts and Catch/Throw
  - Generalized Restarts
  - Interactive Condition Handling
  - Serious Conditions
  - Non-Serious Conditions
  - Condition Types
  - Signaling Conditions
  - Resignaling Conditions
  - Condition Handlers
  - Printing Conditions
- Program Interface to the Condition System
  - Signaling Conditions
  - Assertions
  - Exhaustive Case Analysis
  - Handling Conditions
  - Defining Conditions
  - Creating Conditions
  - Establishing Restarts
  - Finding and Manipulating Restarts
  - Warnings
  - Restart Functions
  - Debugging Utilities
- Predefined Condition Types

Next: Introduction Up: Common Lisp the Language Previous: Functions in the