On 11/15/2015 02:32 PM, Elie Morisse wrote:
On Thursday, 22 October 2015 at 01:19:19 UTC, Andrei Alexandrescu wrote:
Great news! What's the story on exceptions? Does Calypso allow D code
to catch exceptions thrown from C++ code? -- Andrei

Small update: the LDC 0.16.1 merge was done and it's now possible to
catch about any C++ exception with catch (C++) (..) {..} statements.



     Throwing an ooops exception
     Catching the ooops, e.what() == Ooops!

     Throwing another ooops exception
     Catching the std::exception, e.what() == Ooops!

     Now throwing a float
     Catching the float, f == 20.160000!

What's left to implement for full C++ EH support:
  - catching class/struct by value (it's already possible to catch
thrown class values by reference though)
  - thrown object lifetime
  - rethrowing

That's great progress. Do you have documentation for how things work? For example, what's the lifetime of the pointer people will get from std::exception::what().

IMHO: don't worry about catching exceptions by value; it's almost always either incorrect, uninteresting, or both. The prize is catching (references to) classes rooted in std::exception. Nice-to-have is catching (references to) classes rooted in other C++ classes.

A blog post would be fantastic.


Reply via email to