I think there's a lot of potential for delimited continuations in graphics engines, and I plan on using them in what I'm working on. I am using Gambit Scheme however, which does not have a full shift/reset implementation. For the past couple weeks I looked into implementing shift/reset for Gambit (with a fixed dynamic environment), and I got it to work! I posted the following message on the Gambit list earlier today:
"Hello everyone,
I have been studying delimited continuations recently. After being
blissfully enlightened, I really wanted to have them in Gambit (with a
*correct* dynamic environment). I wasn't sure if this was possible
non-natively though (at least safely), because Gambit's dynamic
environment is somewhat complex, and I have to be able to
destructively manipulate the dynamic environment to make sure the
delimited continuation truly has its own dynamic environment 'slice'.
However, I figured out how to (hopefully safely) manipulate Gambit's
dynamic environment, and I have a full implementation of shift/reset
running in Gambit. This implementation is based off Oleg Kiselyov's
work; his paper is here:
http://okmij.org/ftp/Computation/dynamic-binding.html#DDBinding
I am not sure of the performance implications of the Gambit version of
shift/reset. I am unhappy with how much has to happen per reset or
shift, but such is the cost of a non-native implementation.
Unfortunately it goes against the grain of Gambit; after looking at
some of Gambit's internals, Marc obviously has fine-tuned the code to
be very efficient, and each reset or shift call is quite heavy
compared to call/cc. Marc... what are thoughts on a native
implementation of shift/reset?
I included some tests which show that the dynamic environment does
act the way we expect. [see 'tests.scm', snipped the tests out for the sake of this post]
If you are a zipped tar kind of guy:
http://james.tech.coptix.com/files/shift-reset-gambit/shift-reset-gambit.tar.gz
Or you just want the files:
http://james.tech.coptix.com/files/shift-reset-gambit/shift-reset-fixed.scm
http://james.tech.coptix.com/files/shift-reset-gambit/shift-reset-broken.scm
http://james.tech.coptix.com/files/shift-reset-gambit/tests.scm
'shift-reset-fixed.scm' contains the full shift/reset implementation.
'shift-reset-broken.scm' contains a naive implementation with a broken
dynamic environment.
'tests.scm' has some tests to show how the dynamic env is fixed. Note
that at the top you can include 'shift-reset-broken.scm' instead of
the fixed version to see how the dynamic env would normally be broken.
James"