On 10-Jun-1998, Hans Aberg <[EMAIL PROTECTED]> wrote:
>   I think that experts on implementing lazy languages can tell you about
> the problems of implementing C++ "zero-overhead" exceptions (though
> logically equivalent to an exception monad) into a lazy language like
> Haskell.

There's little point trying to implement C++-like so-called "zero-overhead"
exceptions in any language with garbage collection.  It would
probably result in a performance loss.

The "zero-overhead" refers to the time cost of setting up a handler.
Because C++ doesn't have garbage collection, any class that does
dynamic allocation needs a destructor, and for every local variable
with a destructor the implementation needs to set up a handler to
call that destructor when an exception is thrown.  Since classes
with destructors are so common, this needs to be very cheap.
C++ implementations are willing to pay a large space overhead,
plus a significant increase in implementation complexity, plus
an increase in the overhead of actually throwing an exception,
in order to reduce the cost of establishing a handler.
However, in languages with garbage collection, destructors or
finalizers are rare, so there's no need to go to that effort,
and even if you did, the increased space costs and resulting
decreased locality would probably make it not worthwhile.

-- 
Fergus Henderson <[EMAIL PROTECTED]>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED]        |     -- the last words of T. S. Garp.


Reply via email to