[Top][All Lists]
[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: |
Thu, 08 Jul 2004 19:14:48 -0400 |
> Date: Wed, 07 Jul 2004 21:26:21 +0100
> From: Neil Jerram <address@hidden>
> Cc: address@hidden
>
> Gary Houston wrote:
>
> > I wrote something a while ago that I think is relevant to this. In CVS:
> >
> > guile/workbook/extension/dynamic-root.text
>
> Thanks Gary, that's interesting. However, it still doesn't do what I'm
> looking for, I'm afraid, because I actually want to be able to invoke a
> continuation within one C->Scheme entry point that was captured during a
> previous C->Scheme entry point.
>
> I now think that I can achieve what I want by making all the C->Scheme
> entry points look like this:
>
> (define last-c-continuation #f)
>
> (define (entry-point ...)
> (call/cc (lambda (cont)
> (set! last-c-continuation cont)
> (catch #t
> interesting-stuff
> exception-handler)
> (last-c-continuation #f))))
>
> Then, even if `interesting-stuff' invokes a continuation, it will jump
> into a call stack that is identical as far as the high level frames
> shown here are concerned; and the new call stack will still invoke
> last-c-continuation, thus restoring the stack for the containing C code.
>
> Any comments on this, including whether it will or won't work?
It's devious, but I can't think of any reason why it wouldn't work.
Gary