Declining to handle a condition

Джерело:
Common Lisp Tips

Дата публікації:
21/08/2014 21:34

Постійна адреса новини:
http://www.vsinovyny.com/8323844

Declining to handle a condition

 

21/08/2014 21:34 // Common Lisp Tips

Occasionally it is convenient for a handler to decide whether to deal with a condition after it already has control.

Sometimes I see that idiom written with a `handler-case` that resignals the condition if it decides it can’t take care of it. The downside of that approach is that `handler-case` only resignals the condition after unwinding the stack and removing any restarts that were in place.

`handler-bind` avoids those downsides. When a `handler-bind` handler does not transfer control it is said to “decline to handle” the condition. The condition will then percolate up to surrounding handlers or the debugger with the stack and restarts still in tact, as if the handler had never been entered.

(defun baz ()
  (handler-bind ((error (lambda (c)
                          (when (i-got-this-p c)
                            (return-from baz (quux))))))
    (foo)))

 

» Читати повністю

 

« Наступна новина з архіву
When a synonym-stream is useful
  Попередня новина з архіву
Adding an item to a sorted list
»

 

 
© 2026 www.vsinovyny.com