From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA14363; Tue, 11 Jun 2002 17:37:34 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA14519 for ; Tue, 11 Jun 2002 17:37:33 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g5BFbRH18270; Tue, 11 Jun 2002 17:37:27 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA14464; Tue, 11 Jun 2002 17:37:26 +0200 (MET DST) Date: Tue, 11 Jun 2002 17:37:26 +0200 From: Xavier Leroy To: David Chase Cc: caml-list@inria.fr Subject: Re: [Caml-list] Catching exceptions into strings Message-ID: <20020611173726.A14277@pauillac.inria.fr> References: <20020611092333.GJ7647@adelscott.lanetcie.com> <5.1.0.14.0.20020611092123.027cbb48@pop.theWorld.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <5.1.0.14.0.20020611092123.027cbb48@pop.theWorld.com>; from chase@world.std.com on Tue, Jun 11, 2002 at 09:28:06AM -0400 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > That's really rather surprising. Given that the manual recommends that > users explicitly check for zero to avoid this exception The manual suggests that instead of writing try x / y with Division_by_zero -> ... you could also write if y = 0 then ... else x / y and not only avoid the issue, but end up with clearer code as well. However, this kind of transformation isn't always applicable. > , why isn't the > compiler simply inserting the check for them This is a reasonable option -- much more reasonable than trying to intercept the SIGFPE signal and somehow turn it into an exception. I still have doubts that reporting division by zero via an exception is really useful, though. > where it happens to be necessary, and optimizing it out when it is not? I'm more skeptical here. I'm yet to see a practical compile-time analysis that can prove that an integer expression is not zero in any but the most trivial cases (the expression is a constant or a for-loop index). (By "integer", I mean machine integers with modulo arithmetic.) - Xavier Leroy ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners