To implement partial continuations I propose the following new primitives
(reset <thunk>)
Sets a marker flag in the current CallFrame and then executes <thunk>.
(call/pc <unary-proc>)
Creates a copy of all CallFrames from the current frame to the nearest
frame (inclusive) with a set marker flag, or the bottom frame if none is
found. The parent pointer of the copy of the last (i.e. bottom) frame is
set to null. A reference to the copy of the top frame is encapsulated in
a PartialContinuation value that implements Procedure. <unary-proc> is
called with that value as an argument.
(abort <thunk>)
Remove all CallFrames from the current frame to the nearest frame
(inclusive) with a set marker flag, or the bottom frame if none is
found. Then call <thunk>.
When a PartialContinuation is invoked, it creates a copy of all the
CallFrames it contains, and sets the parent pointer of the copy of the
last frame to the Interpreter's current frame. It then pops (i.e. calls)
the copy of the first frame.
At the scheme level all the above then need to be redefined in order to
handle dynamic-wind: invoking a partial k should call the before thunks
that are part of the partial k, and abort should call the after thunks.
Matthias.
-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
|