Into CPS, Never to Return

CPS, or continuation-passing style, is an intermediate representation used in compilers for functional programs like SML and Scheme. In this post, we introduce CPS by building a simple transformation from a Scheme-like language. We cover creating functions, branching, handling variables, implementing function calls, and more in a clear and structured Python code. We discuss optimizations like constant folding and beta reduction. To execute optimized code, options include generating naive C code directly from CPS, using trampolines for tail-call elimination, or implementing the One Big Switch approach. The post provides insights into optimizing, transforming, and executing CPS for those interested in diving deeper.

https://bernsteinbear.com/blog/cps/

To top