[Top][All Lists]

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

Protecting C code from continuations

From: Neil Jerram
Subject: Protecting C code from continuations
Date: Sun, 04 Jul 2004 15:06:12 +0100
User-agent: Mozilla/5.0 (X11; U; Linux 2.4.4-4GB i686; en-US; 0.8.1) Gecko/20010515

Hi all,

I'm working with some C code that is not continuation-safe; specifically, because it will fail in some way if the points of entry from C into Scheme code appear to return more than once. However, it would be useful if I could use continuations to save and restore context as far as the Scheme stack is concerned.

Given this, is there any way of being able to use continuations within Scheme but protecting the C code from them?

I was wondering about using something like this at all the Scheme-from-C entry points ...........

(define-macro (with-continuation-barrier . body)
     (lambda (cont)
         (lambda () ,@body)
         (lambda () (cont #f)))))

..... but I suspect this doesn't work, because when I call a continuation deep within the Scheme code (i.e. the continuation that I really want to use, not the one used as part of the barrier here), that continuation would replace the current dynamic-wind context with the one that was in effect when the continuation was created -- which is exactly what I don't want.

Any comments/ideas?


reply via email to

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