[racket] Tricky Continuations Problem

From: Patrick Li (patrickli.2001 at gmail.com)
Date: Wed Sep 28 21:31:35 EDT 2011

Hello everyone,

I am not that good with continuations, and am having trouble accomplishing
what I want - which is quite trick. A little help and wisdom would be
greatly appreciated.

  (let ((i 0))
    ... computation block 1 ...
    (yield) ;;suspend computation
    (set! i 1)
    ... computation block 2 ...
    (yield) ;;suspend computation
    (set! i 2)
    ... computation block 3 ...
    (yield) ;;suspend computation
    (set! i 3)))

The above code defines a piece of computation that can be suspended and
resumed, and I got that part of it working properly using call/cc. However
the computation also carries some state: the i variable. I would like to
"save" the state of the computation after computation block 1, such that I
can resume it from there over and over with i still equal to 0. Is this
possible using portable R6RS scheme?

Thanks very much for your help!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110928/fcb4be37/attachment.html>

Posted on the users mailing list.