home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!data.nas.nasa.gov!taligent!apple!cambridge.apple.com!cartier@math.uqam.ca
- From: cartier@math.uqam.ca (Guillaume Cartier)
- Newsgroups: comp.lang.lisp.mcl
- Subject: Re: handler-case problem?
- Message-ID: <9211182026.AA15140@mipsmath.math.uqam.ca>
- Date: 18 Nov 92 20:26:08 GMT
- Sender: info-mcl-request@cambridge.apple.com
- Lines: 40
- Approved: comp.lang.lisp.mcl@Cambridge.Apple.C0M
-
- This one should certainly go into a MCL FAQ.
- Almost everyone got bite by this one at one time or another.
-
- <---
- | So when I enter this form I get this behavior:
- | ? (handler-case (/ pi 0) (DIVISION-BY-ZERO (x) (print x)))
- | > Error: While compiling an anonymous function :
- | > Error: "Can't divide by zero."
- | > signalled during compile-time evaluation of (/ 3.141592653589793 0) .
- | > Type Command-. to abort.
- | See the RestartsI menu item for further choices.
- | 1 > (local 7)
- | #<DIVISION-BY-ZERO #x1924C49>
- | 1 > (type-of (local 7))
- | DIVISION-BY-ZERO
- | 1 >
- | Aborted
- | ?
- |
- | Am I doing something wrong or is handler-case used-up?
- | Thanks.
- --->
-
- The problem is that the error occurs during compilation. The compiler
- recognizes 0 as a constant and sees that a division by zero must occur
- and so saves you from the error occuring at runtime.
-
- Try the following:
-
- (let ((x 0))
- (handler-case (/ pi x) (DIVISION-BY-ZERO (x) (print x))))
-
- Guillaume.
-
- *********************************************************************
- * Guillaume Cartier (514) 844-5294 (maison) *
- * L.A.C.I.M. (514) 987-4290 (bureau) *
- * Universite du Quebec a Montreal (514) 987-8477 (telecopieur) *
- * Montreal, Quebec, Canada cartier@math.uqam.ca (internet) *
- *********************************************************************
-