[Haskell-cafe] C++ exception (from *.so) catchable by Haskell??
Peter Simons
simons at cryp.to
Thu Feb 13 23:38:02 UTC 2014
Hi Nick,
please note that the handler set by std::unexpected() fires only if a
function violates its exception specification, i.e. the function
void foobar() throw() { throw 0; }
would trigger std::unexpected_handler(), but
void foobar() { throw 0; }
does not, because there is no "unexpected" exception. Uncaught exceptions,
on the other hand, trigger the function std::terminate(), which by default
translates to std::abort().
Brandon Allbery pointed this out before, but it's probably worth
repeating: there is no way to catch (or throw) a C++ exception in Haskell.
The internal details of C++ exception handling are "implementation
defined". There is no standard that defines how to implement exceptions,
which means that you cannot even mix code from different C++ compilers if
you want to handle exceptions. Mixing in Haskell code is probably next to
impossible.
Take care,
Peter
More information about the Haskell-Cafe
mailing list