Continuation introduction and elimination in higher-order programming languages

Continuations are used in areas as diverse as compiler construction, formal semantics, and proof theory. They represent "the rest of the computation", and are constructed either implicitly using primitive operators (direct style), or explicitly in programs that encode a representation of the control structure (continuation-passing style). The advantages of these approaches are complementary. While explicit continuations are more amenable to further automated analysis, implicit continuations allow the program to remain readable and are typically more efficient. Fortunately, programs can be transformed between these styles automatically. The continuation-passing-style transformation, which introduces explicit continuations, has been studied extensively. Recently, the importance of eliminating explicit continuations has been recognized. This dissertation investigates the relationship between these transformations. We first develop a direct-style transformation to eliminate explicit continuations from continuation-passing-style programs, including programs that require the control operator call/cc. We then identify conditions on the languages of continuation-passing-style and direct-style terms such that the transformations are inverses. Both the continuation-passing-style and direct-style transformations are specified using accumulating parameters. The reasoning techniques developed should be applicable to other programs written in this style. Finally, we illustrate the use of the direct-style transformation in the partial evaluation of programs containing call/cc.