On Saturday, 27 September 2014 at 20:11:34 UTC, Iain Buclaw via
Digitalmars-d wrote:
On 27 September 2014 10:53, Jacob Carlborg via Digitalmars-d
<[email protected]> wrote:
On 2014-09-23 19:37, Andrei Alexandrescu wrote:
We need a libunwind expert to figure out a good approach for
handling
exceptions thrown by C++ code into D.
BTW, are you only interested in handling C++ exception, or are
you
interested in handling D exceptions in C++ as well?
One ugly hack is to register a terminate handler. Then in the
handler
extract the necessary information from the exception, create a
D exception
with this information and throw it as a regular D exception.
Throwing a D exception that should be catchable in C++ is a
bit more tricky.
It's possible to wrap the a call to a D function in a
try-catch block.
Convert the D exception to a C++ exception, then throw it
using a function
part of the C++ exception runtime. The problem here is that
C++ won't be
able to catch this exception because there's no personality
function (or
similar) setup by the D compiler.
Ideally D should just use the same exception mechanism as C++.
I don't think
a language change is necessary for this. Changes in the
compiler, yes, but
hopefully not in the language.
Well, ObjC++ shares the same EH personality routines as C++,
which
probably accounts for the compatibility. :)
Iain.
Is this way acceptable for D, or not. Why?