Re: Article: D Exceptions and C Callbacks

2013-08-10 Thread Walter Bright
On 8/8/2013 2:27 PM, Andrej Mitrovic wrote: What about Error and Throwable? I think those shouldn't pass to the C code either. Unforunately 'nothrow' is a misnomer because it really means 'noexception', it allows both Error and Throwable to propagate from nothrow functions. You're generally on

Re: Article: D Exceptions and C Callbacks

2013-08-09 Thread Mike Parker
On Friday, 9 August 2013 at 14:08:48 UTC, Rene Zwanenburg wrote: - In your second code sample, the D translation of the C code, the line glfwSetWindowCloseCallback( &onWindowClose ); should read either glfwSetWindowCloseCallback( win, &onWindowClose ); or win.glfwSetWindowClos

Re: Article: D Exceptions and C Callbacks

2013-08-09 Thread Rene Zwanenburg
On Tuesday, 6 August 2013 at 15:05:22 UTC, Mike Parker wrote: Shows how I like to deal with throwing exceptions from C callbacks in D. Target audience is beginner-level. Uses GLFW to demonstrate. http://www.gamedev.net/page/resources/_/technical/general-programming/d-exceptions-and-c-callbacks

Re: Article: D Exceptions and C Callbacks

2013-08-08 Thread Marco Leise
Am Thu, 08 Aug 2013 11:33:28 -0700 schrieb Walter Bright : > On 8/8/2013 6:48 AM, Marco Leise wrote: > > I recently proposed using nothrow in GtkD as well. This > > article was kind of a coincidence now. Yes, it is a real issue > > with binding to C code unfortunately. Especially on amd64 with > >

Re: Article: D Exceptions and C Callbacks

2013-08-08 Thread Andrej Mitrovic
On 8/8/13, Walter Bright wrote: > I agree that C callbacks called from C code should be nothrow. > > At a minimum, the C code that calls the callback is not going to be > expecting an > exit via exception, and so may leave things in an indeterminate state. What about Error and Throwable? I think

Re: Article: D Exceptions and C Callbacks

2013-08-08 Thread Walter Bright
On 8/8/2013 6:48 AM, Marco Leise wrote: I recently proposed using nothrow in GtkD as well. This article was kind of a coincidence now. Yes, it is a real issue with binding to C code unfortunately. Especially on amd64 with GCC compiled stuff since it omits the stack frame that DMD requires to unwi

Re: Article: D Exceptions and C Callbacks

2013-08-08 Thread Marco Leise
Am Wed, 07 Aug 2013 12:08:44 +0200 schrieb "Mike Parker" : > On Wednesday, 7 August 2013 at 07:10:21 UTC, Johannes Pfau wrote: > > Am Wed, 07 Aug 2013 03:33:28 +0200 > > schrieb "Mike Parker" : > > > >> > >> > Maybe modifying glfwSetWindowCloseCallback and similar > >> > functions to only accept

Re: Article: D Exceptions and C Callbacks

2013-08-07 Thread Andrej Mitrovic
On 8/7/13, Johannes Pfau wrote: > http://dpaste.dzfl.pl/0f23146f > There's no difference in the generated code, but this way the compiler > will complain if you pass a non-nothrow function to > glfwSetWindowCloseCallback. Although this only stops Exception types from propagating. Error and Throwa

Re: Article: D Exceptions and C Callbacks

2013-08-07 Thread Mike Parker
On Wednesday, 7 August 2013 at 07:10:21 UTC, Johannes Pfau wrote: Am Wed, 07 Aug 2013 03:33:28 +0200 schrieb "Mike Parker" : > Maybe modifying glfwSetWindowCloseCallback and similar > functions to only accept nothrow functions is a good idea? I'm not sure what you mean. That's a C function,

Re: Article: D Exceptions and C Callbacks

2013-08-07 Thread Johannes Pfau
Am Wed, 07 Aug 2013 03:33:28 +0200 schrieb "Mike Parker" : > > > Maybe modifying glfwSetWindowCloseCallback and similar > > functions to only accept nothrow functions is a good idea? > > I'm not sure what you mean. That's a C function, which means it > doesn't have any concept of D's nothrow.

Re: Article: D Exceptions and C Callbacks

2013-08-06 Thread Mike Parker
On Tuesday, 6 August 2013 at 17:54:34 UTC, QAston wrote: There's one thing though. You say than relying on coder's discipline is error prone and I totally agree with that. But your sollution requires coder to remember to wrap those callbacks in try-catches. Programming always requires a cert

Re: Article: D Exceptions and C Callbacks

2013-08-06 Thread QAston
On Tuesday, 6 August 2013 at 15:05:22 UTC, Mike Parker wrote: Shows how I like to deal with throwing exceptions from C callbacks in D. Target audience is beginner-level. Uses GLFW to demonstrate. http://www.gamedev.net/page/resources/_/technical/general-programming/d-exceptions-and-c-callbacks