A generic account of continuation-passing styles

We unify previous work on the continuation-passing style (CPS) transformations in a generic framework based on Moggi's computational meta-language. This framework is used to obtain CPS transformations for a variety of evaluation strategies and to characterize the corresponding administrative reductions and inverse transformations. We establish generic formal connections between operational semantics and equational theories. Formal properties of transformations for specific evaluation orders follow as corollaries. Essentially, we factor transformations through Moggi's computational meta-language. Mapping λ-terms into the meta-language captures computation properties (e.g., partiality, strictness) and evaluation order explicitly in both the term and the type structure of the meta-language. The CPS transformation is then obtained by applying a generic transformation from terms and types in the meta-language to CPS terms and types, based on a typed term representation of the continuation monad. We prove an adequacy property for the generic transformation and establish an equational correspondence between the meta-language and CPS terms. These generic results generalize Plotkin's seminal theorems, subsume more recent results, and enable new uses of CPS transformations and their inverses. We discuss how to aply these results to compilation.

[1]  Peter Zilahy Ingerman,et al.  Thunks: a way of compiling procedure statements with some comments on procedure declarations , 1961, CACM.

[2]  Olivier Danvy,et al.  Representing Control: a Study of the CPS Transformation , 1992, Mathematical Structures in Computer Science.

[3]  Friedrich L. Bauer,et al.  Revised report on the algorithm language ALGOL 60 , 1963, CACM.

[4]  Mark Lillibridge,et al.  Polymorphic type assignment and CPS conversion , 1993, LISP Symb. Comput..

[5]  Amr Sabry,et al.  Reasoning about programs in continuation-passing style , 1992, LFP '92.

[6]  Olivier Danvy,et al.  Back to direct style II: first-class continuations , 1992, LFP '92.

[7]  Olivier Danvy,et al.  CPS-transformation after strictness analysis , 1992, LOPL.

[8]  Philip Wadler,et al.  Comprehending monads , 1990, Mathematical Structures in Computer Science.

[9]  Eugenio Moggi,et al.  Notions of Computation and Monads , 1991, Inf. Comput..

[10]  Julia L. Lawall,et al.  Proofs by structural induction using partial evaluation , 1993, PEPM '93.

[11]  Amr Sabry,et al.  Reasoning about Explicit and Implicit Representations of State , 1993 .

[12]  Eugenio Moggi,et al.  Computational lambda-calculus and monads , 1989, [1989] Proceedings. Fourth Annual Symposium on Logic in Computer Science.

[13]  Alan Mycroft,et al.  The Theory and Practice of Transforming Call-by-need into Call-by-value , 1980, Symposium on Programming.

[14]  Andrew W. Appel,et al.  Compiling with Continuations , 1991 .

[15]  Albert R. Meyer,et al.  Continuation Semantics in Typed Lambda-Calculi (Summary) , 1985, Logic of Programs.

[16]  Jon L. White Proceedings of the 1992 ACM conference on LISP and functional programming , 1992 .

[17]  Luc Moreau,et al.  Sound rules for parallel evaluation of a functional language callcc , 1993, FPCA '93.

[18]  John McCarthy,et al.  Recursive functions of symbolic expressions and their computation by machine, Part I , 1959, Commun. ACM.

[19]  Matthias Felleisen,et al.  Control operators, the SECD-machine, and the λ-calculus , 1987, Formal Description of Programming Concepts.

[20]  Amr Sabry,et al.  The essence of compiling with continuations , 1993, PLDI '93.

[21]  John C. Reynolds,et al.  On the Relation between Direct and Continuation Semantics , 1974, ICALP.

[22]  Olivier Danvy,et al.  Separating stages in the continuation-passing style transformation , 1993, POPL '93.

[23]  Olivier Danvy,et al.  Back to Direct Style , 1992, Sci. Comput. Program..

[24]  Olivier Danvy,et al.  On the Transformation between Direct and Continuation Semantics , 1993, MFPS.

[25]  David A. Schmidt,et al.  Denotationaisemantics: a methodology for language development , 1986 .

[26]  Robert D. Tennent,et al.  Semantics of programming languages , 1991, Prentice Hall International Series in Computer Science.

[27]  Peter Lee,et al.  Call-by-need and continuation-passing style , 1994, LISP Symb. Comput..

[28]  Michael J. Fischer Lambda calculus schemata , 1972 .

[29]  Timothy G. Griffin,et al.  A formulae-as-type notion of control , 1989, POPL '90.

[30]  Peter D. Mosses,et al.  Denotational semantics , 1995, LICS 1995.

[31]  Chetan R. Murthy Extracting Constructive Content From Classical Proofs , 1990 .

[32]  Philip Wadler,et al.  The essence of functional programming , 1992, POPL '92.

[33]  Mitchell Wand Correctness of Procedure Representations in Higher-Order Assembly Language , 1991, MFPS.

[34]  John C. Reynolds,et al.  Definitional Interpreters for Higher-Order Programming Languages , 1972, ACM '72.

[35]  Henk Barendregt,et al.  The Lambda Calculus: Its Syntax and Semantics , 1985 .

[36]  Gordon D. Plotkin,et al.  Call-by-Name, Call-by-Value and the lambda-Calculus , 1975, Theor. Comput. Sci..