Continuation-Passing Style, _(aka) _(CPS), is a paradigm for expressing programs in terms of primitives that explicitly build, pass around and invoke _(continuation)s.

In _(CPS), all the "function calls" are actually jumps to _(continuation)s that never return (so you asymptotically better not waste stack space with them). You can _(macro)-express "normal" function calls into _(CPS) by having the caller jump to the subroutine while giving to it an explicit _(continuation) as an extra argument, and returning for the callee will consist in jumping to that _(continuation) with the return value as argument. That _(continuation) itself refers to the caller's _(continuation) argument, and thus recursively _(reifies|Reification) the whole call chain; at each element of the chain, it also includes the bit of work that has to be done to finish the current function before to return. In other words, the system call stack can be viewed as a _(continuation), and each return addresses (together with the code it points to) can be seen as the static "bit of work remaining to be done" part of a _(continuation).

_(CPS) is notably used to build compiler representations or to extend a _(language) with _(reifiable|Reification) _(continuation)s. These _(continuation)s can then be used to express synchronous remote procedure call in an asynchronous _(distributed) or _(concurrent) system, non-deterministic computations, _(persistent|Persistence) computations, seamless web interface (see Paul Graham paper below), _(GUI)s (see Matthew Fuchs paper below), etc.

Note that _(CPS) builds the sequencing of computations into the representation, so it is rather _(low-level) with respect to pure _(high-level) computations that you'd like to parallelize. On the other hand, this low level of _(abstraction) makes _(CPS) well suited to producing _(assembly) code: indeed, machine code instructions can be viewed as _(CPS) combinators. A particular _(Scheme) compiler using _(CPS) and targetting _(C|C language) is _(chicken|http://cliki.tunes.org/Scheme#chicken).

See also _(FOO-passing Style), _(Monad)s, etc.

<ul class="links">
<li>_("Andrew Appel"|http://www.cs.princeton.edu/~appel/)'s book _("Compiling with Continuation"|http://us.cambridge.org/titles/catalogue.asp?isbn=0521416957);
<li>by _("Paul Graham"|http://www.paulgraham.com/) _("Lisp in Web-Based Applications"|http://www.paulgraham.com/lwba.html); excerpt:
  <blockquote>
  [..]
  <br>
  <strong>Closures Simulate Subroutines</strong>

  One of the problems with using Web pages as a UI is the inherent statelessness of Web sessions. We got around this by using lexical closures to simulate subroutine-like behavior. If you understand about continuations, one way to explain what we did would be to say that we wrote our software in <strong>continuation-passing style</strong>. [..]
  </blockquote>  
<li>by _("Matthew Fuchs"|http://www.cs.nyu.edu/phd_students/fuchs/) _("Escaping the event loop: an alternative control structure for multi-threaded GUIs"|http://www.cs.nyu.edu/phd_students/fuchs/gui.ps.gz) [.ps.gz]; summarizing about contributions of his PhD dissertation, he writes:
  <blockquote>
  [..] How to escape the ubiquitous _(GUI) event loop and eliminate the tortured, dismembered programming style it engenders. The essential realization is that "reactive programming" with callbacks is really a twisted form of <strong>continuation-passing style</strong>, a source code transformation commonly used in compilers for _(functional) languages. [..]
  </blockquote>
<li>Some good intro to _(continuation)s and _(CPS)...
See papers by _(Olivier Danvy), _(Andrzej Filinski), _(Christian Queinnec) (notably his _(Lisp in Small Pieces)), _(Philip Wadler), etc. Ask _(citeseer).
<li>_(Applications of Continuations|http://www.cs.indiana.edu/hyplan/dfried/appcont.pdf), a paper by _(Dan Friedman|http://www.cs.indiana.edu/~dfried/)
<li>...and to A-normal form (ANF):
  <ul>
  <li>_("CPS and A-normal form"|http://www.cs.purdue.edu/homes/suresh/502-Spring2003/lectures/Jan.23-Lecture-4.ppt) [.ppt];
  <li>_("Properties of Terms in Continuation-Passing Style in an Ordered Logical Framework"|http://www.cs.cmu.edu/~fp/talks/lfm00-talk.pdf) [.pdf];
  <li>_("The Essence of Compiling with Continuations"|http://www.cs.indiana.edu/~sabry/papers/essence-retro.pdf) [.pdf];
  <li>_("MATH0069: Programming Language Implementation Techniques - A Normal Form (ANF)"|http://www.cs.bath.ac.uk/~jap/CM30171/anf.html) (_("exams and aswers"|http://www.cs.bath.ac.uk/~jap/CM30171/Old-exam-papers/) for this course: see m69-* files);
  <li>_("CS410/510"|http://www.cs.pdx.edu/~apt/cs510cal_2000/interp2.ps) (.ps) - Compiling Advanced _(Language)s - Spr2000 Lecture Notes - Towards _(Abstract Machines|Abstract VM) II;
  </li>
  </ul>
</ul>