1. Scoping
2. State
3. CPS
3.1. Continuation Passing Style
Definition. Continuation
When executing a program, the program is broken into two parts:
- the current expression being executed, and
- the continuation, which refers to what we do next
Definition. Continuation passing style
Given an expression $e$, it is possible to transform it into a function that takes a continuation $k$ and applies $k$ to the result of evaluating $e$. If we apply this transformation recursively, the result is called continuation passing style (CPS).
3.2. CPS semantics
3.3. CPS Conversion
3.4. Examples
We can write CPS code in Javascript. Here are some examples.