Abstract
While a great deal of attention has been devoted to transforming direct-style (DS) functional programs into continuation-passing style (CPS), to the best of our knowledge, the transformation of CPS programs into direct style has not been investigated. This paper describes the mapping of continuation-passing λ-terms to their applicative-order direct style counterpart. We set up foundations and outline applications of the direct style transformation.
We derive the direct style transformer from a non-standard denotational semantics of the untyped λυ-calculus, that we prove congruent to the standard one.
Under precise conditions (linear occurrences of continuation parameters and no first-class use of continuations due to control operators such as call/cc), we show the DS and the CPS transformations to be inverse.
The direct style transformation can be used in partial evaluation, based on the fact that semantics-based program manipulation performs better when source programs are first transformed into CPS. As a result, specialized programs are expressed in CPS as well. The DS transformation maps them back to direct style.
Part of this work was supported by NSF under grant CCR-9102625. Another part was carried out while visiting Xerox PARC in summer 1991.
Chapter PDF
Similar content being viewed by others
References
Andrew W. Appel. Compiling with Continuations. Cambridge University Press, 1992.
Anders Bondorf. Automatic autoprojection of higher-order recursive equations. Science of Computer Programming, 1991. To appear.
William Clinger and Jonathan Rees, eds. Revised4 report on the algorithmic language Scheme. LISP Pointers, IV(3):1–55, July–September 1991.
Charles Consel and Olivier Danvy. For a better support of static data flow. In Proceedings of the 1991 Conference on Functional Programming and Computer Architecture, number 523 in Lecture Notes in Computer Science, pages 496–519, Cambridge, Massachusetts, August 1991. Springer-Verlag.
Charles Consel and Olivier Danvy. Static and dynamic semantics processing. In Proceedings of the Eighteenth Annual ACM Symposium on Principles of Programming Languages, pages 14–24, Orlando, Florida, January 1991. ACM Press.
Olivier Danvy. Three steps for the CPS transformation. Technical Report CIS-92-2, Kansas State University, Manhattan, Kansas, 1992.
Olivier Danvy and Andrzej Filinski. Abstracting control. In LFP'90 [23], pages 151–160.
Olivier Danvy and Andrzej Filinski. Representing control, a study of the CPS transformation. Technical Report CIS-91-2, Kansas State University, Manhattan, Kansas, 1991.
Olivier Danvy and Julia L. Lawall. Back to direct style II: First-class continuations. Technical Report CIS-92-1, Kansas State University, Manhattan, Kansas, 1992.
Matthias Felleisen, Daniel P. Friedman, Eugene Kohlbecker, and Bruce Duba. A syntactic theory of sequential control. Theoretical Computer Science, 52(3):205–237, 1987.
Matthias Felleisen and Robert Hieb. The revised report on the syntactic theories of sequential control and state. Technical Report Rice COMP TR89-100, Department of Computer Science, Rice University, Houston, Texas, June 1989. To appear in Theoretical Computer Science.
Andrzej Filinski. Declarative continuations: An investigation of duality in programming language semantics. In D.H. Pitt et al., editors, Category Theory and Computer Science, number 389 in Lecture Notes in Computer Science, pages 224–249, Manchester, UK, September 1989.
Michael J. Fischer. Lambda calculus schemata. In Proceedings of the ACM Conference on Proving Assertions about Programs, pages 104–109. SIGPLAN Notices, Vol. 7, No 1 and SIGACT News, No 14, January 1972.
Pascal Fradet and Daniel Le Métayer. Compilation of functional languages by program transformation. ACM Transactions on Programming Languages and Systems, 13:21–51, 1991.
Daniel P. Friedman. Applications of continuations. Report 237, Computer Science Department, Indiana University, Bloomington, Indiana, January 1988. Tutorial of the Fifteenth Annual ACM Symposium on Principles of Programming Languages, San Diego, California.
Daniel P. Friedman, Mitchell Wand, and Christopher T. Haynes. Essentials of Programming Languages. MIT Press and McGraw-Hill, 1991.
Timothy G. Griffin. A formulae-as-types notion of control. In Proceedings of the Seventeenth Annual ACM Symposium on Principles of Programming Languages, pages 47–58, San Francisco, California, January 1990. ACM Press.
Neil D. Jones and Alan Mycroft. Data flow analysis of applicative programs using minimal function graphs. In Proceedings of the Thirteenth Annual ACM Symposium on Principles of Programming Languages, pages 296–306, January 1986.
Neil D. Jones and Flemming Nielson. Abstract interpretation: a semantics-based tool for program analysis (chapter in preparation). In The Handbook of Logic in Computer Science. North-Holland, 1991.
Neil D. Jones, Peter Sestoft, and Harald Søndergaard. MIX: A self-applicable partial evaluator for experiments in compiler generation. LISP and Symbolic Computation, 2(1):9–50, 1989.
Richard Kelsey and Paul Hudak. Realistic compilation by program transformation. In Proceedings of the Sixteenth Annual ACM Symposium on Principles of Programming Languages, pages 281–292, Austin, Texas, January 1989.
Amir Kishon, Paul Hudak, and Charles Consel. Monitoring semantics: A formal framework for specifying, implementing, and reasoning about execution monitors. In Proceedings of the ACM SIGPLAN'91 Conference on Programming Languages Design and Implementation, pages 338–352, Toronto, Ontario, June 1991.
Proceedings of the 1990 ACM Conference on Lisp and Functional Programming, Nice, France, June 1990.
Antoni W. Mazurkiewicz. Proving algorithms by tail functions. Information and Control, 18:220–226, 1971.
Eugenio Moggi. Computational lambda-calculus and monads. In Proceedings of the Fourth Annual Symposium on Logic in Computer Science, pages 14–23, Pacific Grove, California, June 1989. IEEE.
Chetan R. Murthy. An evaluation semantics for classical proofs. In Proceedings of the Sixth Symposium on Logic in Computer Science, Amsterdam, The Netherlands, July 1991. IEEE.
Flemming Nielson. A denotational framework for data flow analysis. Acta Informatica, 18:265–287, 1982.
Flemming Nielson and Hanne Riis Nielson. Two-level semantics and code generation. Theoretical Computer Science, 56(1):59–133, January 1988.
Gordon D. Plotkin. Call-by-name, call-by-value and the λ-calculus. Theoretical Computer Science, 1:125–159, 1975.
John C. Reynolds. Definitional interpreters for higher-order programming languages. In Proceedings of 25th ACM National Conference, pages 717–740, Boston, 1972.
David A. Schmidt. Denotational Semantics: A Methodology for Language Development. Allyn and Bacon, Inc., 1986.
Guy L. Steele Jr. Rabbit: A compiler for Scheme. Technical Report AI-TR-474, Artificial Intelligence Laboratory, Massachusetts Institute of Technology, Cambridge, Massachusetts, May 1978.
Christopher Strachey and Christopher P. Wadsworth. Continuations: A mathematical semantics for handling full jumps. Technical Monograph PRG-11, Oxford University Computing Laboratory, Programming Research Group, Oxford, England, 1974.
Adriaan van Wijngaarden. Recursive definition of syntax and semantics. In T. B. Steel, Jr., editor, Formal Language Description Languages for Computer Programming, pages 13–24. North-Holland, 1966.
Philip Wadler. Comprehending monads. In LFP'90 [23], pages 61–78.
Mitchell Wand. Semantics-directed machine architecture. In Proceedings of the Ninth Annual ACM Symposium on Principles of Programming Languages, pages 234–241, January 1982.
Mitchell Wand. A short proof of the lexical addressing algorithm. Information Processing Letters, 35:1–5, 1990.
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1992 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Danvy, O. (1992). Back to direct style. In: Krieg-Brückner, B. (eds) ESOP '92. ESOP 1992. Lecture Notes in Computer Science, vol 582. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-55253-7_8
Download citation
DOI: https://doi.org/10.1007/3-540-55253-7_8
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-55253-6
Online ISBN: 978-3-540-46803-5
eBook Packages: Springer Book Archive