Back to direct style

Olivier Danvy
1994 Science of Computer Programming  
This paper describes the transformation of I-terms from continuation-passing style (CPS) to direct style. This transformation is the left inverse of Plotkin's left-to-right call-by-value CPS encoding for the pure I-calculus. Not all I-terms are CPS terms, and not all CPS terms encode a left-to-right call-byvalue evaluation. These CPS terms are characterized here; they can be mapped back to direct style. In addition, the two transformations-to continuation-passing style and to direct style-are
more » ... ctored using a language where all intermediate values are named and their computation is sequentialized. The issue of proper tail-recursion is also addressed. Much work has been devoted to transforming programs into continuationpassing style (CPS). (For a recent survey, see Talcott's special issue on continuations [23].) In a CPS program, all procedures take an extra parameter-the continuation-which is a functional accumulator representing "the rest of the computation". As a consequence, all calls are tail-calls. By contrast, programs that are not in CPS (e.g., programs before CPS transformation) are said to be in "direct style" (DS). Their procedure calls can occur anywhere (i.e., not necessarily in tail position).
doi:10.1016/0167-6423(94)00003-4 fatcat:gbui3kno4fbrlnbud77vlbypcu