English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Catching exceptions into strings
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-06-14 (21:23)
From: John Carr <jfc@M...>
Subject: Re: [Caml-list] Catching exceptions into strings

> > , 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.

I don't see the problem with translating SIGFPE into an exception.
The same technique is used for bounds checking.  On SPARC/Solaris
SIGILL becomes an array bounds error.  To handle SIGFPE similarly
requires about five lines of code per platform in asmrun/signals.c
plus about 20 lines of code in asmrun/fail.c to generate the
appropriate exception.

If the language defines a divide-by-zero exception then the runtime
should generate the exception.  I can think of only one reason not
to do so on a platform where division by zero results in a signal:
the core dump may be easier to debug than an uncaught exception.
(How about a stack trace on error for compiled code?)

    --John Carr (jfc@mit.edu)
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