this is what a continuation is

By 8 nic on March 08, 2007

it is the continuing execution of a function by calling another function.

So in Javascript we might say:

function dosomething(y, x)
{
y=y*10;
return x(y);
}

dosomething(17, function (z) { return z / 10; });

which when called will result in the value 17.

The function "x" being passed to the function "dosomething" is a continuation. We can say that function "dosomething" calls a continuation.

Scheme (and some other programming languages) have specific support for continuations so you can capture the current continuation as a function and then pass it to another function. If you capture the continuation at some point and pass it to another function which eventually calls it, the effect is to leap back to the point at which the continuation was captured.

It's exactly like a longjmp in C, and indeed that's one of the ways you can implement it if you're writing a Scheme evaluator.

Continuations are becoming trendy in terms of the web because they can quite conveniently contain long running stateful conversations. This is mostly bad because it's not RESTful.

Embed Claim Make a related claim

Discussion

Sign in in to leave a comment.