in functional programming, continuation-passing style (cps) is a style of programming in which control is passed explicitly in the form of a continuation. gerald jay sussman and guy l. steele, jr. coined the phrase in ai memo 349 (1975), which sets out the first version of the scheme programming language. john c. reynolds gives a detailed account of the numerous discoveries of continuations. a function written in continuation-passing style takes an extra argument: an explicit "continuation" i.e. a function of one argument. when the cps function has computed its result value, it "returns" it by calling the continuation function with this value as the argument. that means that when invoking a cps function, the calling function is required to supply a procedure to be invoked with the subroutine's "return" value. expressing code in this form makes a number of things explicit which are implicit in direct style. these include: procedure returns, which become apparent as calls to a continuation; intermediate values, which are all given names; order of argument evaluation, which is made explicit; and tail calls, which simply call a procedure with the same continuation, unmodified, that was passed to the caller. programs can be automatica
Continuations Functional_programming Implementation_of_functional_programming_languages