good evening,

On 16 Apr 2014, at 09:53, Christophe Rhodes <> wrote:

Attila Lendvai <> writes:

i just had a thought on WITH-DEADLINE while guarding a piece of code

 (serious-condition ()

this seems to be a reasonable piece of code, but if it's used in a
context where there is a deadline installed, and if that deadline is
signalled from inside of it, then it'll muffle the deadline.

is this code bad style?

I would say "yes": handling all SERIOUS-CONDITIONs indiscriminately (and
moving on) is likely to be a bad thing.  The SERIOUS-CONDITIONs that are
not ERRORs are things that are conceptually the computer going wrong:
running out of heap or stack space, detecting memory corruption
errors -- the kinds of thing that probably warrant something more than
being caught by a generic handler-case.

ERRORs, by contrast, are conventionally things going wrong with the
program or its execution.  I don't know whether deadlines are
conceptually ERRORs or SERIOUS-CONDITIONs, but even if they're
implemented that way it doesn't make it OK to handle all the other kinds
of ways in which the computer can go wrong.

even once one has reduced the class of conditions which are handled, a second issue remains: one may need to distinguish handling within that class.
for this situation, it can be useful that the type specifications from the clauses are tested in order and each handler executes in a dynamic context in which the others are not visible.

Welcome to Clozure Common Lisp Version 1.9-r15759  (DarwinX8664)!
? (handler-case (+ 1 a)
    (type-error (e) (signal e) e)
    (condition (c) (cons :muffle c)))
;Compiler warnings :
;   In an anonymous lambda form at position 19: Undeclared free variable A
(:MUFFLE . #<UNBOUND-VARIABLE #x30200106F95D>)
? (handler-case (+ 1 "a")
    (type-error (e) (signal e) e)
    (condition (c) (cons :muffle c)))
#<TYPE-ERROR #x3020010DFD0D>
? (handler-bind ((type-error (lambda (e) (print (cons :resignaled e)))))
    (handler-case (+ 1 "a")
      (type-error (e) (print (cons :resignaling e)) (signal e) e)
      (condition (c) (cons :muffle c))))

(:RESIGNALING . #<TYPE-ERROR #x302001186D1D>) 
(:RESIGNALED . #<TYPE-ERROR #x302001186D1D>) 
#<TYPE-ERROR #x302001186D1D>

james anderson | |