From: "Nicolas Cannasse" <ncannasse@motion-twin.com>
To: "Alessandro Baretta" <a.baretta@barettadeit.com>
Cc: "skaller" <skaller@users.sourceforge.net>, <caml-list@inria.fr>
Subject: Re: [Caml-list] Seeking exception source
Date: Tue, 8 Nov 2005 19:06:53 +0900 [thread overview]
Message-ID: <002201c5e44c$25f15eb0$0c05a8c0@PWarp> (raw)
In-Reply-To: <43707E30.2040405@barettadeit.com>
>>> I am occasionally annoyed by Not_found propagating to my
>>> top level function .. meaning the error could be anywhere
>>> at all in my program.
>>
>>
>> At that time the best is to run your program in bytecode with debug infos
>> using ocamlrun -b so you'll get full backtrace informations. It would be
>> better for such debug informations (not all the types but only the
>> bytecode -> source positions) to be included by default, and always have
>> backtrace turned on.
>
> In many cases this is completely inadequate. The AS/Xcaml application
> server, for example, cannot terminate on an uncaught exception in a
> program module. The main loop must catch the exception and do its best to
> report it, without aborting the execution of the server. This means that I
> need to get the backtrace within Ocaml code by applying some kind of
> function to the exception object. I tried to write a C function providing
> this kind of information, but I never managed to get it to work.
>
> Alex
Yes I agree, this is not all the time easy to get exceptions backtraces
since it's only possible for uncaught ones. At some time I managed to modify
the Ocaml interpreter to make it work, by exporting some C inner interpreter
functions but I'm not sure it was a correct hack.
On the NekoVM which some design points are inspired by the OCaml VM, I
recently added exception stack traces. In fact, I was thinking that this
will cost more performances than it actualy did. The impact on the
bootstrapping time of NekoML was quite low. It's true that the compiler
being written in an ML language, quite often exceptions are used to control
the flow of the program (Not_found , Eof and Exit among others). But since
in general the position of catching is just a few calls away from the throw,
you don't have to unwind a lot of debug informations.
It is also useful in that case to have a "reraised" semantic that will keep
the stack when an execption is filtered. But OCaml have that. Having full
exceptions backtraces plus call stack traces available at anytime is a big
plus when working on the NekoML compiler. The tagged union printers
automaticaly generated and carried with instances are helping a lot too,
since you can "print" polymorphicaly any runtime value. I think this is very
small things that would greatly ease the everyday ocaml programmer life.
Nicolas Cannasse
next prev parent reply other threads:[~2005-11-08 10:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-08 2:13 skaller
2005-11-08 2:57 ` [Caml-list] " Jon Harrop
2005-11-08 9:06 ` Nicolas Cannasse
2005-11-08 10:30 ` Alessandro Baretta
2005-11-08 10:06 ` Nicolas Cannasse [this message]
2005-11-08 10:34 ` skaller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='002201c5e44c$25f15eb0$0c05a8c0@PWarp' \
--to=ncannasse@motion-twin.com \
--cc=a.baretta@barettadeit.com \
--cc=caml-list@inria.fr \
--cc=skaller@users.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).