User Tools

Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
continuation_passing_style [2012/10/23 23:42]
will created
continuation_passing_style [2015/02/02 08:28] (current)
Line 1: Line 1:
 ====== Continuation passing style ====== ====== Continuation passing style ======
  
 +More commonly, functions return a value directly this is called direct style.
  
-[algorithm continuation passing style]+[algorithm continuation passing style-direct] 
 + 
 +Continuation passing style (CPS) is a style of programming where the control is passed directly as a continuation ​ function. A function written in CPS takes an extra argument which is an explicit continuation,​ a function which takes the return result as a single argument. 
 + 
 +[algorithm continuation passing style-continuation] 
 + 
 +This makes some things more explicit, such as returning values. Which allows for more control over how these aspects of programming function. A simple example of control over returning values is delaying the time at which the value is returned. 
 + 
 +[algorithm continuation passing style-delayed] 
 + 
 +Continuations are not just limited to a single return continuation. The Javascript interpreter that runs the code in these examples takes 6 different continuations. These handle control flow for things like breaking from for loops and exceptions.
continuation_passing_style.1351060960.txt.gz · Last modified: 2015/02/02 08:24 (external edit)