I need a macro that systematically catches an error (in my case, an
underflow error) and returns a given value instead, like in :
(with-minimum-float
(format t "format: ~A~%" 1.0E-500)
(list (exp -1000) (/ 1.0E-308 1E50)))
getting:
format: 2.0E-308
(2.0E-308 2.0E-308)
I know how to write particular functions my-exp, my-*, my-/ etc... to do this
using the basic things I understand about handler-bind and restart-case, but
I can't solve the case of several errors in the same body, each returning the
value. I know how to return 0.0 using the LCL (enabled-floating-point-traps)
construct, too.
Is there a solution ?
--
Eric Dedieu (···········@imag.fr)
LIFIA - 46 av. Felix Viallet, 38031 Grenoble Cedex, France
Tel: 76 57 46 11 - Fax: 76 57 46 02 - Dom: 76 49 78 80
In article <····················@imag.fr> ······@imag.fr (Eric Dedieu) writes:
>(with-minimum-float
> (format t "format: ~A~%" 1.0E-500)
> (list (exp -1000) (/ 1.0E-308 1E50)))
>
>getting:
>
>format: 2.0E-308
>(2.0E-308 2.0E-308)
Unfortunately, this isn't possible in general. Common Lisp defines the
conditions that should be signalled, but doesn't require the built-in
mathematical functions to establish restart handlers to allow you to
specify alternate return values when the conditions are signalled. It
probably would have made sense to specify that they establish a USE-VALUE
restart, but we didn't (that restart is only specified for CELL-ERROR and
its descendants).
--
Barry Margolin ······@netcom.com