chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] throwing exception from C


From: felix winkelmann
Subject: Re: [Chicken-users] throwing exception from C
Date: Sun, 20 Mar 2005 14:13:37 +0100

On Thu, 17 Mar 2005 07:52:52 +0000, John Lenz <address@hidden> wrote:
> 
> Is this the right way to throw an exception from C code? 

Yes, this looks fine.

> My only concern
> is that we are calling C_do_apply from inside the catch { } block, so when
> throwing an exception the catch { is still left on the stack which might
> impact future throws later on the stack.  We don't want C++ unrolling the
> stack all the way back up to this function if another exception is thrown.
> Perhaps it won't, since an exception thrown from inside a catch block
> propagates up to it's parent.  Secondly, C++ exceptions do not propagate
> across C code (at least for gcc), unless the C code is compiled with
> -fexceptions, in which case the chicken runtime might "protect" us from
> exceptions going every which way.
> 

Uh, I don't know how C++ implements exceptions. Unless any global 
chain of exceptions is kept, I would think this should work. If future throws
are still caught by (future) wrappers, the excception shouldn't propagate
beyond the most recent handler. Also, once the next minor GC has cleaned up
the stack, there isn't anything to return to on a throw. Does longjmp/setjmp
play well with C++ exceptions? Or is there any information available on how
C++ exceptions are (usually) implemented?


cheers,
felix




reply via email to

[Prev in Thread] Current Thread [Next in Thread]