[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Condition handling
Date: 28 Sep 90 10:43:00 MDT
From: alames@sandia.gov (2814 AMES, ARLO L.)
I need a bit of help with condition handling. I have a routine that
occasionally divides by zero, getting a CLI::SIGNAL-DOUBLE-FLOAT-TRAP.
The <RESUME> response, returning infinity, is appropriate here. Such
division happens OFTEN, and I'd like to use something like CONDITION-BIND
and SYS:PROCEED to simply take the resume response. Any examples of how
to do it?
Thanks,
Arlo Ames
ALAMES@SANDIA.GOV
The following code is what I use for divide by zero handling.
;;; -*- Mode: LISP; Base: 10. -*-
(defun handler (self)
(send self :proceed :my-action))
(defmethod (sys:float-divide-by-zero :case :proceed :my-action) (&optional (x +1e))
"This is my proceed type."
(values :new-value x))
(defmethod (sys:divide-by-zero :case :proceed :my-action) (&optional (x +1e))
"This is my proceed type."
(if (zerop (car dbg:operands))
(setq x 0))
(values :return-values (list x)))
(defmethod (sys:float-divide-zero-by-zero :case :proceed :my-action) (&optional (x 0))
"This is my proceed type."
(values :new-value x))
(condition-bind ((sys:divide-by-zero 'handler))
(// 0.0 0))
Don Kaiser
Boeing