On 9/24/14, 5:12 AM, Iain Buclaw via Digitalmars-d wrote:
On 24 September 2014 12:27, IgorStepanov via Digitalmars-d
<[email protected]> wrote:
On Tuesday, 23 September 2014 at 17:37:42 UTC, Andrei Alexandrescu wrote:

We need a libunwind expert to figure out a good approach for handling
exceptions thrown by C++ code into D.

Is anyone fluent with libunwind?


Andrei


Is there plans to catching C++ exceptions in D?

I'd say no to such an idea.

I understand the difficulty of it. However, we should look into it closely. Preventing D code from catching C++ exceptions forces one to implement the driver/event loop/etc in C++, which is quite unpleasant. It essentially takes C++ compatibility a few good notches down.

What kind of C++ exceptions planned to catch in D?

None

I wonder how difficult would be to create a wrapper class CppException for everything derived from C++ std::exception. It would not save the exact exception, but it would save its what() string and perhaps the typeid().name(). A translator would create CppException objects from std::exception objects and their derivatives.

How hard would that be? Please advise.

For example C++ can throw primitive types exceptions, for example int.
Of cource, them can be wrapped into special D CPPException : Throwable,
class, which contains string representation of C++ exception.
What about C++ polymorthic exceptions? AFAIK, C++ exception are throwing
by-value, and catching by ref (to allow polimorthic catch). Where C++ calls
destructor for exception? In catch block? In D GC handles an exception
lifetime.
Is there any ideas about it?
P.S. I tell about user-side of catching C++ exceptions, not about
implementation.

Let C++ land catch the exception and deal with it.

Believe me, I hear you :o). I'm afraid we need to do something better about it.


Andrei

Reply via email to