[LLVMdev] OCaml and Exceptions

Sandro Magi naasking at gmail.com
Sun Nov 25 20:38:58 PST 2007

On Nov 25, 2007 5:23 PM, Jon Harrop <jon at ffconsultancy.com> wrote:
> On Sunday 25 November 2007 22:16, Eric Christopher wrote:
> > That said, I don't know much about OCaml and so don't know if this
> > philosophy fits the standard OCaml programming style. If throw/catch/etc are
> > meant to be normal path of execution then a small cost up front in, for
> > example, try blocks could easily speed up execution later when you hit the
> > throw.
> Exceptions are often raised and caught in OCaml programs so an optimizing
> OCaml compiler would be expected to provide very fast throwing and catching
> of exceptions.
> However, optimizing them now when we already have an easy to use exception
> mechanism would be premature: I'd like to get something useful up and running
> first and leave these kinds of optimizations.

Exception handling can be naively handled via closures, so the
amortized cost is an indirect function call. This requires some
program transformation where try-catch expressions are lifted into
their own functions and passed to callers. What does OCaml actually do
in this case?


More information about the llvm-dev mailing list