guile-user
[Top][All Lists]
Advanced

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

Re: Protecting C code from continuations


From: Gary Houston
Subject: Re: Protecting C code from continuations
Date: Tue, 06 Jul 2004 15:50:33 -0400

> Date: Mon, 05 Jul 2004 23:31:04 +0100
> From: Neil Jerram <address@hidden>
> 
> Steve Tell wrote:
> 
> > On Sun, 4 Jul 2004, Neil Jerram wrote:
> > 
> > 
> >> Hi all,
> >> 
> >> I'm working with some C code that is not continuation-safe; [...]
> >> 
> >> Any comments/ideas?
> > 
> > 
> > Might (call-with-dynamic-root thunk) be what you want?
> 
> Thanks for reminding me - I had forgotten about call-with-dynamic-root 
> (cwdr).  However, I'm not sure that it gives me what I need, because I 
> believe that a continuation captured within one cwdr cannot then be 
> invoked within a different cwdr.
> 
> To explain further: in my program, the main loop is in C; some events 
> from the main loop are handled purely within C code, while others are 
> dispatched into Scheme.  The way I want to use continuations is such 
> that a Scheme coder can write
> 
> (begin
>    (do-thing-1)
>    (do-thing-2)
>    (do-thing-3))
> 
> without having to worry about the fact that (do-thing-2) will usually 
> have to escape and then let the C main loop run for a few iterations 
> until the information needed to complete (do-thing-2) comes back.
> 
> So, the continuation to "finish (do-thing-2) and then continue" needs to 
> be captured within one call from C into Scheme, but invoked within some 
> later call from C into Scheme (not necessarily the next such call).
> 
> Obviously (I think!) I can implement this using CPS 
> (continuation-passing style), and then define convenience macros to try 
> to hide the CPS, but it would be much nicer to use real continuations if 
> that is possible.

I wrote something a while ago that I think is relevant to this. In CVS:

guile/workbook/extension/dynamic-root.text 

Regards,
Gary





reply via email to

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