[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: So, what the heck is a continuation anyway?

Dan Sugalski wrote:
> Are there general rules as to where you're allowed to return to? I presume
> picking PC addresses out of the air's considered bad form.

In Scheme, you generate the "PC address" by saying
"call-with-current-continuation" (shortcut: call-cc).  It calls a
function, passing the current continuation as an argument. The
continuation object looks like a function (of course, in scheme, it
would look like a function). In Stackless Python it looks like an object
with a .call method. If you aren't comfortable with Scheme, consider
playing with them in Stackless Python.


Continuations are not something you would expect many programmers to
use. IMO, most programmers should work with pre-defined control
structures, not invent their own! Exception handling, co-operative
microthreads, coroutines and generators are all control flow structures
that can be implemented on top of continuations.

 Paul Prescod