Hi,
Stefan and Mark, I think you are talking past each other. Stefan is offering a very concrete definition of what he wants, and Mark is looking for a more abstract version. Here is what I think Stefan wants, in the language of R5RS' storage model:
A variable is simply a name for a particular location, and each variable refers to its own unique location. When a continuation is captured, that continuation gets its own set of "mirror" locations, one for each variable that is in the scope of the continuation. These "mirror" locations are initialized with the same values that were in the locations of the corresponding variables, but they are distinct from those locations and are immutable.
When a continuation is called, it is run in an environment in which each of the variables that was in scope when it was captured points to a new location, which is initialized to have the same value as the corresponding "mirror" location.
Note that each variable name gets at least three distinct locations in this description: the original location, when the program was being run, the "mirror" location, when the continuation was captured, and the new location, when the continuation was called. I believe this is sufficient (and necessary?) to give the semantics that Stefan wants.
Let me also give a more concrete example, which I believe captures *why* this is important. Let's say you're writing a loop with a counter that says when to terminate:
(let ((count 0))
(let iter ()
... do-some-stuff ...
(when (< count 1000000)
(set! count (+ count 1))
(iter))))
Now pretend that do-some-stuff captures its continuation when count is equal to 10. Stefan wants a situation where, no matter how many times that continuation is called, *each call* to the continuation will have (= count 10). I think this is very natural if you're using an imperative style, but I'm not sure what the best way is to achieve it.
Best,
Noah