ABSTRACT
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 m eta-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.Andrew W. Appel. Compiling with Continuations. Cambridge University Press, 1992. Google ScholarDigital Library
- 2.Henk Barendregt. The Lambda Calculus -- Its Syntax and Semantics. North-Holland, 1984.Google Scholar
- 3.Geoffrey Burn and Daniel Le M~tayer. Proving the correctness of compiler optimisations based on a global program analysis. Technical report Doc 92/20, Department of Computing, Imperial College of Science, Technology and Medicine, London, England, 1992.Google Scholar
- 4.William Clinger, editor. Proceed, ngs of the 1992 A CM Conference on Lisp and Functional Programmzng, LISP Pointers, Vol. V, No. 1, San Francisco, California, June 1992. ACM Press.Google Scholar
- 5.Olivier Danvy. Three steps for the CPS transformation. Technical Report CIS-92-2, Kansas State University, Manhattan, Kansas, December 1991.Google Scholar
- 6.Olivier Danvy. Back to direct style. Science of Computer Programm,ng, 1993. Special issue on ESOP'92, the Fourth European Symposium on Programming, Rennes, February 26-28, 1992. To appear. Google ScholarDigital Library
- 7.Olivier Danvy and Andrzej Filinski. Representing control, a study of the CPS transformation. In Wand {44}, pages 361-391.Google Scholar
- 8.OIivier Danvy and John Hatcliff. CPS transformation. after strictness analysis. A CM Letters on Programming Languages and Systems, 1(3):195-212, 1993. Google ScholarDigital Library
- 9.Olivier Danvy and John Hatcliff. On the transformation between direct and continuation semantics. In Stephen Brookes, Michael Main, Austin Melton, Michael Mislove, and David Schmidt, editors, Proceedings of the 9th Conference on Mathematical Foundations of Programming Semantics, Lecture Notes in Computer Science, New Orleans, Louisiana, April 1993. To appear. Google ScholarDigital Library
- 10.Olivier Danvy and Julia L. Lawall. Back to direct style iI: First-class continuations. In Clinger {4}, pages 299- 310. Google Scholar
- 11.Matthias Felleisen and Daniel P. Friedman. Control operators, the SECD machine, and the A-calculus. In M. Wirsing, editor, Formal Description of Programming Concepts III, pages 193-217. North-Holland, 1986.Google Scholar
- 12.Michael J. Fischer. Lambda-calculus schemata. In Talference on Proving Assertions about Programs, SIG- PLAN Notices, Vol. 7, No. 1, January 1972. Google ScholarDigital Library
- 13.Cormac Flanagan, Amr Sabry, Bruce F. Duba, and Matthias FeUeisen. The essence of compiling with continuations. In David W. Wall, editor, Proceedings of the A CM SIGPLAN'93 Conference on Programming Languages Design and Implementation, SIGPLAN Notices, Vol. 28, No 6, pages 237-247, Albuquerque, New Mexico, June 1993. ACM Press. Google ScholarDigital Library
- 14.Timothy G. Griffin. A formulae-as-types notion of control. In Paul Hudak, editor, Proceedings of the Seventeenth Annual A CM Symposium on Principles o:f Programming Languages, pages 47-58, San Francisco, California, January 1990. ACM Press. Google ScholarDigital Library
- 15.Bob Harper ~rtd Mark Lilhbridgc. Polymorphic type assignment and CPS conversion. In Talcott {39}. Google ScholarDigital Library
- 16.John Hatcliff. PhD thesis, Department of Computing and Information Sciences, Kansas State University, Manhattan, Kansas, USA, March 1994. Forthcoming.Google Scholar
- 17.John Hatcliff and Ohvier Danvy. Thunks and the )~- calculus. Technical Report CIS-93-15, Kansas State University, Manhattan, Kansas, September 1993.Google Scholar
- 18.Peter Z. Ingerm~n. Thunks, a way of compiling procedure statements with some comments on procedure declarations. Communications of the A CM, 4(1):55-58, 1961. Google ScholarDigital Library
- 19.Jufia L. Lawall. PhD thesis, Computer Science Department, Indiana University, Bloomington, Indiana, USA, 1993. Forthcoming.Google Scholar
- 20.Julia L. LawaI1. Proofs by structural induction using partial evaluation. In David A. Schmidt, editor, Proceedings of the Second A CM SIGPLAN Symposium on Partial Evaluation and Semantics-Based Program Manipulation, pages 155-166, Copenhagen, Denmark, June 1993. ACM Press. Google ScholarDigital Library
- 21.Julia L. Lawall and Olivier Danvy. Separating stages in the continuation-passing style transformation, in Susan L. Graham, editor, Proceedings of the Twentieth Annual A CM Symposium on Principles of Programming Languages, pages 124-136, Charleston, South Carolina, January 1993. ACM Press. Google ScholarDigital Library
- 22.Albert R. Meyer and Mitchell Wand. Continuation semantics in typed lambda-calculi (summary). In Rohit Parikh, editor, Logics of Programs- Proceedings, number 193 in Lecture Notes in Computer Science, pages 219-224, Brooklyn, June 1985. Google ScholarDigital Library
- 23.Eugenio Moggi. Computational lambda-calculus and monads. Report ECS-LFCS-88-66, University of Edinburgh, Edinburgh, Scotland, October 1988.Google Scholar
- 24.Eugenio Moggi. Computational lambda-calculus and monads. In Proceedings of the Fourth Annual IEEE Symposium on Logic in Computer Science, pages 14-23, Pacific Grove, California, June 1989. IEEE Computer Society Press. Google ScholarDigital Library
- 25.Eugenio Moggi. An abstract view of programming languages. Course notes ECS-LFCS-90-113, Laboratory for Foundations of Computer Science, Department of Computer Science, University of Edinburgh, Edinburgh, Scotland, April 1990.Google Scholar
- 26.Eugenio Moggi. Notions of computation and monads. Information and Computation, 93:55-92, 1991. Google ScholarDigital Library
- 27.Luc Moreau and Daniel Ribbens. Sound rules for parallel evaluation of a functional language with callcc. In Arvind, editor, Proceedings of the Sixth A CM Conference on Functional Programming and Computer Architecture, pages 125-135, Copenhagen, Denmark, June 1993. ACM Press. Google ScholarDigital Library
- 28.Chetan R. Murthy. Extracting Constructive Content from Classical Proofs. PhD thesis, Department of Computer Science, Cornell University, 1990. Google ScholarDigital Library
- 29.Alan Mycroft. The theory and practice of transforming call-by-need into call-by-value. In Bernard Robinet, editor, Proceedings of the Fourth International Symposium on Programming, number 83 in Lecture Notes in Computer Science, pages 269-281, Paris, France, April 1980. Google ScholarDigital Library
- 30.Peter Naur (editor). Revised report on the algorithmic language Algol 60. Communications of the A CM, 6(1):1-17, 1962. Google ScholarDigital Library
- 31.Chris Okasaki, Peter Lee, and David Tarditi. Call-byneed and continuation-passing style. In Talcott {39}.Google Scholar
- 32.Gordon D. Plotkin. Call-by-name, call-by-value and the )~-calculus. Theoretical Computer Science, 1:125-159, 1975.Google ScholarCross Ref
- 33.John C. Reynolds. Definitional interpreters for higherorder programming languages. In Proceedings of 25th A CM National Conference, pages 717-740, Boston, 1972. Google ScholarDigital Library
- 34.John C. Reynolds. On the relation between direct and continuation semantics. In Jacques Loeckx, editor, 2nd Colloquium on Automata, Languages and Programming, number 14 in Lecture Notes in Computer Science, pages 141-156, Saarbriicken, West Germany, July 1974. Google Scholar
- 35.Amr Snbry ~md Matthias Felleisen. Reasoning about programs in continuation-passing style. In Clinger {4}, pages 288-298. Google Scholar
- 36.Amr Sabry and Matthias Felleisen. Reasoning about programs in continuation-passing style. In Talcott {39}. Google ScholarDigital Library
- 37.Amr Sabry and John Field. Reasoning about explicit and implicit representation of state. In Paul Hudak, editor, Proceedings of the A CM SIGPLAN Workshop on State in Programming Languages, pages 17-30, Copenhagen, Denmark, June 1993.Google Scholar
- 38.David A. Schmidt. Denotational Semantics: A Methodology for Language Development. Altyn and Bacon, Inc., 1986. Google ScholarDigital Library
- 39.Carolyn L. Talcott, editor. Special issue on continuations, LISP and Symbolic Computation, Vol. 6, Nos. 3/4. Kluwer Academic Publishers, 1993.Google Scholar
- 40.Robert D. Tennent. Semantics of Programming Languages. Prentice-Hall International, Englewood Cliffs, New Jersey, 1991. Google ScholarDigital Library
- 41.Philip Wadler. Comprehending monads. In Wand {44}, pages 461-493. Google Scholar
- 42.Philip Wadler. The essence of functional programming (tutorial). In Andrew W. Appel, editor, Proceedings of the Nineteenth Annual A CM Symposium on Principles of Programming Languages, pages 1-14, Albuquerque, New Mexico, January 1992. ACM Press. Google ScholarDigital Library
- 43.Mitchell Wand. Correctness of procedure representations in higher-order assembly language. In Stephen Brookes, Michael Main, Austin Melton, Michael Mislove, and David Schmidt, editors, Mathematical Foundations of Programming Semantics, volume 598 of Lecture Notes in Computer Science, pages 294-311, Pittsburgh, Pennsylwtnia, March 1991. 7th International Conference. Google ScholarDigital Library
- 44.Mitchell Wand, editor. Special issue on the 1990 A CM Conference on Lisp and Functional Programming, Mathematical Structures in Computer Science, Vol. 2, No. 4. Cambridge University Press, December 1992.Google Scholar
Index Terms
- A generic account of continuation-passing styles
Recommendations
Separating stages in the continuation-passing style transformation
POPL '93: Proceedings of the 20th ACM SIGPLAN-SIGACT symposium on Principles of programming languagesThe continuation-passing style (CPS) transformation is powerful but complex. Our thesis is that this transformation is in fact compound, and we set out to stage it. We factor the CPS transformation into several steps, separating aspects in each step: (1)...
A Proof Theoretical Account of Continuation Passing Style
CSL '02: Proceedings of the 16th International Workshop and 11th Annual Conference of the EACSL on Computer Science LogicWe study the "classical proofs as programs" paradigm in Call-By-Value (CBV) setting. Specifically, we show the CBV normalization for CND (Parigot 92) can be simulated by the cut-elimination procedure for LKQ (Danos-Joinet-Schellinx 93), namely the q-...
Comments