Condition Systems
in an
Exceptional Language
Clojure/Conj 2015
Chouser
Outline
Actual Outline
“T
he action taken after detecting a software error (e.g., returning error codes) should be uniform for all components in the system. This leads to the difficult question of what action to take when an error is detected. The best action is immediately to terminate the program.”
Myers, Glenford J. (1976) Software Reliability Principles & Practices
Error response options
Erlang,
Tru64 Unix
Error response options
Dramatic
Subtle
Error response options
Common Lisp
Error response options
Java NPE
Error response options
(Math/sqrt -2)
(first [])
Error response options
C’s errno
(agent-errors a)
Error response options
Linux “oops”
Error response options
Who chooses response?
Practical Common Lisp, Peter Seibel
Error response options
Who chooses response?
Error response options
Who chooses response?
Error response options
Who chooses response?
Condition System
aka Resumable Exceptions / Conditions / Errors
aka Restarts
Common Lisp
slingshot & swell
not needed
define-condition
make-condition
error / signal
handler-case
restart-case
invoke-restart
throw+
handler-bind
restart-case
invoke-restart
Old:
New:
Old:
New:
Error response options
Who chooses response?
Condition system libraries
A composition problem
Awesome app
library A
library B
A composition problem
Awesome app
library A
library B
ribol
bwo/conditions
A composition problem
Awesome app
library A
library B
ribol
bwo/conditions
swell:
builtin:
...
*malformed-log-entry-error*
*malformed-entry-error*
*error*
*math-error*
*sqrt-of-negative*
Handler! Decline to handle!
hose who regularly code for fast electronic computers will have learned from bitter experience that a large fraction of the time spent in preparing calculations for the machine is taken up in removing the blunders that have been made in drawing up the programme. With the aid of common sense and checking subroutines the majority of mistakes are quickly found and rectified. Some errors, however, are sufficiently obscure to escape detection for a surprisingly long time.”
“T
R. A. Brooker, S. Gill, and D. J. Wheeler, “The Adventures of a Blunder,”
Mathematical Tables and Other Aids to Computation, 6 (38), 112-113 (1952).
“V
ast opportunities that we software developers have to make models that prove and expand human knowledge, but we’re too busy plumbing.”
References
Images:
Books:
Papers:
Harvard Mark II, 1947
1943 - Colossus
1947 - moth
1952 - Brooker
1976 - Myers
1987 - Felleisen
1997 - Moreau
2007 - Clojure