Comment 1 for bug 1916302

Revision history for this message
Richard M Kreuter (kreuter) wrote :

Interesting catch. HANDLER-BIND turns out to wrap complex handler forms in a lambda, which delays evaluation of that form until the time of signaling, and also evaluates that form each time SIGNAL is called (which is why you're getting a fresh closure each time).

* (handler-bind ((condition (progn (print 'making-a-handler) (constantly nil))))
    (dotimes (i 2) (print 'running) (signal 'condition)))

RUNNING
MAKING-A-HANDLER
RUNNING
MAKING-A-HANDLER
NIL

Doesn't seem right to me. Attaching a patch that pulls out the evaluation of complex handler forms to happen just once.