continuations


What are continuations?

Continuations can be defined as "The future of a computation.". Given the simple statement:

 (- 2 (+ 3 4)) 

(- 2 [...] ) is the continuation of (+ 3 4).

Typically, when procedures return a value, what they really do is call their continuation with that value. Take the example above, the value passed to (- 2 [...]) is 7, and is inserted in the square brackets. Do not confuse the value (the integer 7 in this case) with the continuation. They are 2 separate things.

Now, when it is said that Scheme has first-class continuations, that means that we can access the continuation of a computation as a value. In our simple example, we can capture the continuation of (+ 3 4) and bind its value in a variable for later use. You would perform this capture and storage with the scheme procedure call-with-current-continuation.

What continuations are not

An incorrect analogy that is often used is that continuations are gotos with arguments. However, this is what procedure calls in continuation-passing-style are. Continuations themselves represent much more than just addresses to pass arguments to.


category-learning-scheme