|
|
|
|
|
by antonvs
1891 days ago
|
|
Yes. Check out the book "Compiling with Continuations" by Andrew Appel. Not only can a compiler "convert direct style to CPS under the hood," it's one of the more efficient and effective ways to implement a compiler. At a high level, CPS provides an intermediate form that's well suited to transformation into machine-oriented forms like machine code and bytecode, but is still high-level enough to be able to support both human and automated reasoning. Also see the paper, "A Correspondence between Continuation Passing Style and Static Single Assignment Form"[1] which describes the equivalence between SSA, commonly used in imperative language compilers, and CPS. This is one of the many cases where a well-motivated functional solution turns out to be one of the better solutions to a problem, to the point that a version of it is used even in imperative contexts. [1] https://www.cs.purdue.edu/homes/suresh/502-Fall2008/papers/k... |
|