Skip to Content
Programming Languages: Concepts and Implementation
book

Programming Languages: Concepts and Implementation

by Saverio Perugini
December 2021
Beginner
840 pages
47h 29m
English
Jones & Bartlett Learning
Content preview from Programming Languages: Concepts and Implementation

13.10 CPS Transformation

A program written using recursive control behavior can be mechanically rewritten in CPS (i.e., iterative control behavior), and that mechanical process is called CPS conversion. The main idea in CPS conversion is to transform the program so that implicit continuations are represented as closures manipulated by the program. The informal steps involved in this process are:

  1. Add a formal parameter representing the continuation to each lambda expression.

  2. Pass an anonymous function representing a continuation in each function call.

  3. Use the passed continuation in the body of each function definition to return a value.

The CPS conversion involves a set of rewrite rules from a variety of syntactic constructs (e.g., conditional ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Concepts and Semantics of Programming Languages 1

Concepts and Semantics of Programming Languages 1

Therese Hardin, Mathieu Jaume, Francois Pessaux, Veronique Viguie Donzeau-Gouge
Programming C# 10

Programming C# 10

Ian Griffiths

Publisher Resources

ISBN: 9781284222739