Chemistry Reference and  Research
           
 
Periodic Table
- standard table
- large table
 
Chemical Elements
- by name
- by symbol
- by atomic number
 
Chemical Properties
 
Chemical Reactions
 
Organic Chemistry
 
Branches of Chemistry
Analytical chemistry
Biochemistry
Computational Chemistry
Electrochemistry
Environmental chemistry
Geochemistry
Inorganic chemistry
Materials science
Medicinal chemistry
Nuclear chemistry
Organic chemistry
Pharmacology
Physical chemistry
Polymer chemistry
Supramolecular Chemistry
Thermochemistry

Continuation passing style

Continuation passing style is a style of functional programming, in which every function takes the continuation waiting for its return value as an explicit argument. Instead of returning a value to its caller directly, the function returns the result of applying the continuation to what it would normally have returned.

Here is an example in Scheme:

Normal programming style
Continuation passing style
(define (mysqrt x) (sqrt x))
(define (mysqrt x k) (k (sqrt x)))
(+ (mysqrt 4) 2)
(mysqrt 4 (lambda (x k) (k (+ x 2))))

Continuation passing style can be used to implement continuations in a functional language that does not feature first class continuations but has first class functions.

As continuation passing style renders return values virtually useless, it can also be used to eliminate the need for a stack and return values entirely. Several interpreters for functional programming languages use this concept internally.

01-04-2007 01:16:19
The contents of this article are licensed from Wikipedia.org under the GNU Free Documentation License. How to see transparent copy