Catching C++ std::exception in D

2015-11-11 Thread Walter Bright via Digitalmars-d
In order to interoperate with modern C++, it has been abundantly clear for some time that D needs some support for C++ exception handling: 1. Have D finally blocks executed in D code that sits between a C++ try and catch 2. Have C++ finally blocks executed in C++ code that sits between a D try

Re: Catching C++ std::exception in D

2015-11-11 Thread krzaq via Digitalmars-d
On Thursday, 12 November 2015 at 06:50:31 UTC, Walter Bright wrote: In order to interoperate with modern C++, it has been abundantly clear for some time that D needs some support for C++ exception handling: [...] What about rethrowing C++ exceptions? Are we going to use pointer notation for

Re: Catching C++ std::exception in D

2015-11-11 Thread krzaq via Digitalmars-d
On Thursday, 12 November 2015 at 07:47:16 UTC, Kagamin wrote: On Thursday, 12 November 2015 at 07:00:43 UTC, krzaq wrote: What about rethrowing C++ exceptions? Are we going to use pointer notation for C++ exceptions? This may be the same under the hood, but looks way different. std::exception

Re: Catching C++ std::exception in D

2015-11-11 Thread Kagamin via Digitalmars-d
On Thursday, 12 November 2015 at 07:00:43 UTC, krzaq wrote: What about rethrowing C++ exceptions? Are we going to use pointer notation for C++ exceptions? This may be the same under the hood, but looks way different. std::exception is class, i.e. reference type, so you won't be able to throw

Re: Catching C++ std::exception in D

2015-11-12 Thread Iain Buclaw via Digitalmars-d
On 12 November 2015 at 07:50, Walter Bright via Digitalmars-d < digitalmars-d@puremagic.com> wrote: > In order to interoperate with modern C++, it has been abundantly clear for > some time that D needs some support for C++ exception handling: > > 1. Have D finally blocks executed in D code that si

Re: Catching C++ std::exception in D

2015-11-12 Thread Jacob Carlborg via Digitalmars-d
On 2015-11-12 07:50, Walter Bright wrote: 3. Be able to catch in D code an std::exception* or a C++ class derived from that. In would be nice if we were able to catch Objective-C exceptions as well (it uses the same exception handling as C++). They have their own tree of exception classes wh

Re: Catching C++ std::exception in D

2015-11-12 Thread Iain Buclaw via Digitalmars-d
On 12 November 2015 at 09:59, Jacob Carlborg via Digitalmars-d < digitalmars-d@puremagic.com> wrote: > On 2015-11-12 07:50, Walter Bright wrote: > > 3. Be able to catch in D code an std::exception* or a C++ class derived >> from that. >> > > In would be nice if we were able to catch Objective-C ex

Re: Catching C++ std::exception in D

2015-11-12 Thread Walter Bright via Digitalmars-d
On 11/12/2015 12:57 AM, Iain Buclaw via Digitalmars-d wrote: I don't mind the compiler-specific personality, gdc has one, __gcd_personality_v0. I don't see a way out of not having one. but a new throw function? I guess I should count my lucky stars that I'm still using the original _d_throw

Re: Catching C++ std::exception in D

2015-11-12 Thread Walter Bright via Digitalmars-d
On 11/12/2015 12:59 AM, Jacob Carlborg wrote: In would be nice if we were able to catch Objective-C exceptions as well (it uses the same exception handling as C++). They have their own tree of exception classes which do not inherit from std::exception. We don't need to support this right away but

Re: Catching C++ std::exception in D

2015-11-12 Thread Iain Buclaw via Digitalmars-d
On 12 November 2015 at 07:50, Walter Bright via Digitalmars-d < digitalmars-d@puremagic.com> wrote: > > I really appreciate the offers, and here's what will really help: > > Writing the druntime end of things, which is really providing just two > functions: d_throw (d_dwarf_throw to distinguish it

Re: Catching C++ std::exception in D

2015-11-12 Thread Walter Bright via Digitalmars-d
On 11/12/2015 2:08 AM, Iain Buclaw via Digitalmars-d wrote: Writing the druntime end of things, which is really providing just two functions: d_throw (d_dwarf_throw to distinguish it) and the libunwind personality function: __dmd_personality_v0. The tricky part with the personalit

Re: Catching C++ std::exception in D

2015-11-12 Thread deadalnix via Digitalmars-d
On Thursday, 12 November 2015 at 10:09:10 UTC, Iain Buclaw wrote: On 12 November 2015 at 07:50, Walter Bright via Digitalmars-d < digitalmars-d@puremagic.com> wrote: I really appreciate the offers, and here's what will really help: Writing the druntime end of things, which is really provid

Re: Catching C++ std::exception in D

2015-11-12 Thread Jacob Carlborg via Digitalmars-d
On 2015-11-12 10:40, Walter Bright wrote: I don't anticipate that would be too difficult to add. Great :) -- /Jacob Carlborg

Re: Catching C++ std::exception in D

2015-11-12 Thread Iain Buclaw via Digitalmars-d
On 12 November 2015 at 10:36, Walter Bright via Digitalmars-d < digitalmars-d@puremagic.com> wrote: > On 11/12/2015 12:57 AM, Iain Buclaw via Digitalmars-d wrote: > >> I don't mind the compiler-specific personality, >> > > gdc has one, __gcd_personality_v0. I don't see a way out of not having one.

Re: Catching C++ std::exception in D

2015-11-12 Thread Iain Buclaw via Digitalmars-d
On 12 November 2015 at 11:17, deadalnix via Digitalmars-d < digitalmars-d@puremagic.com> wrote: > On Thursday, 12 November 2015 at 10:09:10 UTC, Iain Buclaw wrote: > >> On 12 November 2015 at 07:50, Walter Bright via Digitalmars-d < >> digitalmars-d@puremagic.com> wrote: >> >> >>> I really appreci

Re: Catching C++ std::exception in D

2015-11-12 Thread Jacob Carlborg via Digitalmars-d
On 2015-11-12 11:37, Iain Buclaw via Digitalmars-d wrote: In any case, I'm doubtful that forwarding to C++'s personality would work. Objective-C does that [1]. [1] http://www.opensource.apple.com/source/objc4/objc4-647/runtime/objc-exception.mm search for "__objc_personality_v0" -- /Jacob

Re: Catching C++ std::exception in D

2015-11-12 Thread Elie Morisse via Digitalmars-d
On Thursday, 12 November 2015 at 06:50:31 UTC, Walter Bright wrote: In order to interoperate with modern C++, it has been abundantly clear for some time that D needs some support for C++ exception handling: 1. Have D finally blocks executed in D code that sits between a C++ try and catch 2. H

Re: Catching C++ std::exception in D

2015-11-12 Thread Johannes Pfau via Digitalmars-d
Am Thu, 12 Nov 2015 11:31:39 +0100 schrieb Iain Buclaw via Digitalmars-d : > On 12 November 2015 at 10:36, Walter Bright via Digitalmars-d < > digitalmars-d@puremagic.com> wrote: > > > On 11/12/2015 12:57 AM, Iain Buclaw via Digitalmars-d wrote: > > > >> I don't mind the compiler-specific perso

Re: Catching C++ std::exception in D

2015-11-12 Thread Dan Olson via Digitalmars-d
Johannes Pfau writes: > To expand on this: I think we'd prefer one __d_personality_v0 which is > implemented in upstream druntime and identical for all compilers. Speacking of upstream support. GDC support SjLj exceptions. In 2.067, it became obvious that Fiber needed separate SjLj context stac

Re: Catching C++ std::exception in D

2015-11-12 Thread David Nadlinger via Digitalmars-d
On Thursday, 12 November 2015 at 16:55:09 UTC, Johannes Pfau wrote: To expand on this: I think we'd prefer one __d_personality_v0 which is implemented in upstream druntime and identical for all compilers. Making the compilers ABI compatible is probably not a high priority, but OTOH we shouldn

Re: Catching C++ std::exception in D

2015-11-12 Thread David Nadlinger via Digitalmars-d
On Thursday, 12 November 2015 at 06:50:31 UTC, Walter Bright wrote: The tricky part with the personality function will likely be recognizing std::exception* exceptions. I wonder if forwarding the call to __gxx_personality_v0 will work. This should be rather simple; you know it is C++ because o

Re: Catching C++ std::exception in D

2015-11-12 Thread deadalnix via Digitalmars-d
On Thursday, 12 November 2015 at 10:56:01 UTC, Jacob Carlborg wrote: On 2015-11-12 11:37, Iain Buclaw via Digitalmars-d wrote: In any case, I'm doubtful that forwarding to C++'s personality would work. Objective-C does that [1]. [1] http://www.opensource.apple.com/source/objc4/objc4-647/run

Re: Catching C++ std::exception in D

2015-11-12 Thread Johannes Pfau via Digitalmars-d
Am Thu, 12 Nov 2015 09:59:14 -0800 schrieb Dan Olson : > Johannes Pfau writes: > > To expand on this: I think we'd prefer one __d_personality_v0 which > > is implemented in upstream druntime and identical for all > > compilers. > > Speacking of upstream support. GDC support SjLj exceptions.

Re: Catching C++ std::exception in D

2015-11-13 Thread Dan Olson via Digitalmars-d
Johannes Pfau writes: > Am Thu, 12 Nov 2015 09:59:14 -0800 > schrieb Dan Olson : > >> Johannes Pfau writes: >> > To expand on this: I think we'd prefer one __d_personality_v0 which >> > is implemented in upstream druntime and identical for all >> > compilers. >> >> Speacking of upstream suppo

Re: Catching C++ std::exception in D

2015-11-13 Thread Iain Buclaw via Digitalmars-d
On 13 November 2015 at 18:45, Dan Olson via Digitalmars-d < digitalmars-d@puremagic.com> wrote: > Johannes Pfau writes: > > > Am Thu, 12 Nov 2015 09:59:14 -0800 > > schrieb Dan Olson : > > > >> Johannes Pfau writes: > >> > To expand on this: I think we'd prefer one __d_personality_v0 which > >>

Re: Catching C++ std::exception in D

2015-11-14 Thread Dan Olson via Digitalmars-d
Dan Olson writes: > Johannes Pfau writes: > >> Am Thu, 12 Nov 2015 09:59:14 -0800 >> schrieb Dan Olson : >> >>> Johannes Pfau writes: >>> > To expand on this: I think we'd prefer one __d_personality_v0 which >>> > is implemented in upstream druntime and identical for all >>> > compilers. >>>

Re: Catching C++ std::exception in D

2015-11-14 Thread David Nadlinger via Digitalmars-d
On Friday, 13 November 2015 at 18:40:06 UTC, Iain Buclaw wrote: There may be a few other holes between how Fibers and EH interact. https://github.com/D-Programming-Language/druntime/commit/f6633abb43ea1f2464d3a772b8f8fe78216ffd8e The SJLJ stack switching should probably be added to this mech

Re: Catching C++ std::exception in D

2015-11-14 Thread Elie Morisse via Digitalmars-d
Sorry for the delay, here's the initial commit for C++ exception catching in Calypso: https://github.com/Syniurge/Calypso/commit/8b55ec1f013c29df86455ab055fbba91a72d92af https://github.com/Syniurge/druntime/commit/d33d8bf32c739bf9a30705dfc764718c817f16b1 The main files of interest are: https:/

Re: Catching C++ std::exception in D

2015-11-14 Thread Dan Olson via Digitalmars-d
David Nadlinger writes: > On Friday, 13 November 2015 at 18:40:06 UTC, Iain Buclaw wrote: >> There may be a few other holes between how Fibers and EH interact. >> >> https://github.com/D-Programming-Language/druntime/commit/f6633abb43ea1f2464d3a772b8f8fe78216ffd8e > > The SJLJ stack switching sho