Get the latest tech news
Into CPS, Never to Return
CPS, or continuation-passing style, is an intermediate representation for programs, particularly functional programs. It’s used in compilers for languages such as SML and Scheme.
To “return”, we use$call-cont as usual, but we have to also remember to create a new fun form with a continuation parameter (and then thread that through to the function body). We also add this new compiler builtin called($if cond iftrue iffalse) that takes one trivial expression—the condition—and decides which of the branches to execute. I had originally planned to write a CPS-based optimizer and code generator for scrapscript but I got stuck on the finer details of compiling pattern matching to CPS.
Or read this on Hacker News