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