[racket] Implementing delimited continuations using a CPS transform

From: Patrick Li (patrickli.2001 at gmail.com)
Date: Thu Nov 24 02:31:28 EST 2011

Hello everyone,

Does anyone know of a guide on how delimited continuations (reset/shift)
can be implemented using a CPS transform? There is a paper for doing this
in Scala, but I don't have a CS background and cannot understand the

I thought it might be similar to implementing full continuations using a
CPS transform (which I know how to do), but I'm not sure if my solution is
the cleanest. Normally, in the CPS transform, each function is extended to
take an extra continuation argument. My solution is to extend every
function with an additional return-to-reset continuation on top of the
extra continuation argument. This 2nd continuation is used by "shift"
commands to return to the enclosing "reset", and the original 1st
continuation is used to return to the caller.

Does that sound sensible?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20111123/6c0a61e6/attachment.html>

Posted on the users mailing list.