Continuation |
: This page is about the computer science continuation. See analytic continuation for the use of the term in complex analysis; see Continuation War for the Finno-Soviet conflict during World War II; and see Continuing patent application for the special type of patent application.
In Computing, a continuation is a representation of an execution point (for example, the instruction pointer and stack frame). Many languages have constructs that allow a programmer to obtain a pointer to a continuation, and then to resume execution using the pointer at a later point in time. This technique has been used in functional programming, imperative programming, and message passing programming.
Continuations are also used in models of computation including the Actor model, Process calculi, and the lambda calculus. Christopher Strachey, C.P. Wadsworth and John Reynolds brought the term continuation into prominence in their work in the field of denotational semantics that makes extensive use of continuations to allow sequential programs to be analysed in terms of functional programming semantics.
=Programming language support=
Many programming languages exhibit such a feature under various names; specifically:
*Scheme programming language: call/cc (short for call-with-current-continuation) *SML programming language: SMLofNJ.Cont.callcc
=Kinds of continuations=
Support for continuations varies widely. A programming language supports re-invocable continuations if a continuation may be invoked repeatedly (even after it has already returned). Re-invocable continuations were introduced by Peter Landin using his J (for Jump) operator that could perform a nonlocal goto into the middle of a procedure invocation. Re-invocable continuations have also been called re-entrant in the MzScheme programming language. However this use of the term re-entrant is too easily confused with its use in discussions of computer multitasking.
At one time Gerry Sussman and Drew McDermott thought that using re-invocable continuations (which they called Hairy Control Structure ) was the solution to the AI control structure problems that had originated in Planner_programming_language. Carl Hewitt et. al. developed message passing as an alternative solution in the Actor model. Guy Steele and Gerry Sussman then developed in the continuations in Scheme in their attempt to understand the Actor model.
A more limited kind is the escape continuation that may be used to escape the current context to a surrounding one. Many languages which do not explicitly support continuations support .
=Disadvantages=
Continuations are the functional expression of the GOTO statement, and the same caveats apply. While they are a sensible option in some special cases, use of continuations can result in code that is difficult to follow. In fact, the esoteric programming language Unlambda includes call-to-current-continuation as one of its features solely because of its resistance to understanding. The external links below illustrate the concept in more detail.
=See also=
*Continuation passing style *closure (computer science) *Coroutine *spaghetti stack *denotational semantics *GOTO *COMEFROM
=External links=
*[http://www.ps.uni-sb.de/~duchier/python/continuations.html Continuations Made Simple and Illustrated]. An explanation, using the Python programming language. *[http://www.intertwingly.net/blog/2005/04/13/Continuations-for-Curmudgeons Continuations for Curmudgeons] by Sam Ruby *[http://www.stackless.com/spcpaper.htm Continuations and Stackless Python] by Christian Tismer *[http://www.linuxgazette.com/issue90/raghu.html setjmp/longjmp Illustrated] from Linux Gazette *[http://www.cs.bham.ac.uk/~hxt/cw04/cw04-program.html On-line proceedings of the Fourth Workshop on Continuations] *[http://www.cs.bham.ac.uk/~hxt/research/Logiccolumn8.pdf Continuation, functions and jumps] *[http://www.deepwood.net/~mikael/continuations/ Using continuations for web programming] *[http://wiki.apache.org/cocoon/RhinoWithContinuations Rhino With Continuations] *[http://rifers.org/wiki/display/RIFE/Web+continuations Continuations in pure Java] from the RIFE web application framework *[http://rifers.org/theater/debugging_continuations Debugging continuations in pure Java] from the RIFE web application framework
= References =
*Peter Landin. A Generalization of Jumps and Labels Report. UNIVAC Systems Programming Research. August 1965. Reprinted in Higher Order and Symbolic Computation. 1998. *Drew McDermott and Gerry Sussman. The Conniver Reference Manual MIT AI Memo 259. May 1972. *Daniel Bobrow: A Model for Control Structures for Artificial Intelligence Programming Languages IJCAI 1973. *Carl Hewitt, Peter Bishop and Richard Steiger. A Universal Modular Actor Formalism for Artificial Intelligence IJCAI 1973. *Christopher Strachey and C.P. Wadsworth. Continuations: a Mathematical semantics for handling full jumps. Technical Monograph PRG-11. Oxford University Computing Laboratory. January 1974. *John Reynolds. On the Relation between Direct and Continuation Semantics. Proceedings of Second Colloquium on Automata, Languages, and Programming. 1974. *Gerald Sussman and Guy Steele. SCHEME: An Interpreter for Extended Lambda Calculus AI Memo 349, MIT Artificial Intelligence Laboratory, Cambridge, Massachusetts, December 1975. *Robert Hieb, R. Kent Dybvig, Carl Bruggeman. Representing Control in the Presence of First-Class Continuations. Proceedings of the ACM SIGPLAN 90 Conference on Programming Language Design and Implementation *Will Clinger, Anne Hartheimer, Eric Ost. Implementation Strategies for Continuations. Proceedings of the 1988 ACM conference on LISP and functional programming . 1988.|
|