This question is not a technical but a historical one. I was just thinking today that I\'ve also thought of Java as the \"first\" language to use exception handling, until I
The errorset function in Lisp 1.5, described in a 1962 reference manual, is an early form of exception handling. In The Evolution of Lisp, Gabriel and Steele make these remarks, evidently getting the name of the operator slightly wrong and simplifying its syntax (P. 9-10):
In Lisp 1.5, certain built-in functions might signal errors, when given incorrect arguments, for example. Signaling an error normally resulted in program termination or invocation of a debugger. Lisp 1.5 also had the function ERRSET , which was useful for controlled execution of code that might cause an error. The special form
(errset form)evaluates form in a context in which errors do not terminate the program or enter the debugger. If form does not cause an error, ERRSET returns a singleton list of the value. If execution of form does cause an error, the ERRSET form quietly returns NIL .
MacLisp added the function ERR , which signals an error. If ERR is invoked within the dynamic context of an ERRSET form, then the argument to ERR is returned as the value of the ERRSET form.
Programmers soon began to use ERRSET and ERR not to trap and signal errors but for more general control purposes (dynamic non-local exits). Unfortunately, this use of ERRSET also quietly trapped unexpected errors, making programs harder to debug. A new pair of primitives, CATCH and THROW , was introduced into MacLisp in June 1972 so that ERRSET could be reserved for its intended use of error trapping.
The manual has, of course, the details, on Page 34, section "6.4 The Cons Counter and Errorset".
It looks like errorset interacts with the "cons counter", a memory allocation watchdog. The user of errorset must specify an integer value n, which specifies how many cons cells can be allocated in the protected computation before a trap will occur.
The description ends with these words:
If an error occurs inside of an errorset, then the value of errorset is NIL. If vari- ables bound outside of the errorset have not been altered by using cset or set, and if no damage has been done by pseudo-functions, it may be possible to continue computation in a different direction when one path results in an error.
This clearly shows that the construct is suitable for locally trapping an error, and then recovering (continuing computation "in a different direction when one path results in an error").
ANSI Common Lisp "conditions" show a lot of inspiration from the PL/I "conditions" system. However, PL/I was first available in 1966, a few years after Lisp 1.5's errset. The first PL/I reference manual, dated 1965, does already describe ON-units and conditions.