Back to direct style

Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 582)


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.


Direct style transformation continuation-passing style transformation λυ-calculus Scheme 


  1. [1]
    Andrew W. Appel. Compiling with Continuations. Cambridge University Press, 1992.Google Scholar
  2. [2]
    Anders Bondorf. Automatic autoprojection of higher-order recursive equations. Science of Computer Programming, 1991. To appear.Google Scholar
  3. [3]
    William Clinger and Jonathan Rees, eds. Revised4 report on the algorithmic language Scheme. LISP Pointers, IV(3):1–55, July–September 1991.Google Scholar
  4. [4]
    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.Google Scholar
  5. [5]
    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.Google Scholar
  6. [6]
    Olivier Danvy. Three steps for the CPS transformation. Technical Report CIS-92-2, Kansas State University, Manhattan, Kansas, 1992.Google Scholar
  7. [7]
    Olivier Danvy and Andrzej Filinski. Abstracting control. In LFP'90 [23], pages 151–160.Google Scholar
  8. [8]
    Olivier Danvy and Andrzej Filinski. Representing control, a study of the CPS transformation. Technical Report CIS-91-2, Kansas State University, Manhattan, Kansas, 1991.Google Scholar
  9. [9]
    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.Google Scholar
  10. [10]
    Matthias Felleisen, Daniel P. Friedman, Eugene Kohlbecker, and Bruce Duba. A syntactic theory of sequential control. Theoretical Computer Science, 52(3):205–237, 1987.Google Scholar
  11. [11]
    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.Google Scholar
  12. [12]
    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.Google Scholar
  13. [13]
    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.Google Scholar
  14. [14]
    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.Google Scholar
  15. [15]
    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.Google Scholar
  16. [16]
    Daniel P. Friedman, Mitchell Wand, and Christopher T. Haynes. Essentials of Programming Languages. MIT Press and McGraw-Hill, 1991.Google Scholar
  17. [17]
    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.Google Scholar
  18. [18]
    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.Google Scholar
  19. [19]
    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.Google Scholar
  20. [20]
    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.Google Scholar
  21. [21]
    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.Google Scholar
  22. [22]
    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.Google Scholar
  23. [23]
    Proceedings of the 1990 ACM Conference on Lisp and Functional Programming, Nice, France, June 1990.Google Scholar
  24. [24]
    Antoni W. Mazurkiewicz. Proving algorithms by tail functions. Information and Control, 18:220–226, 1971.Google Scholar
  25. [25]
    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.Google Scholar
  26. [26]
    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.Google Scholar
  27. [27]
    Flemming Nielson. A denotational framework for data flow analysis. Acta Informatica, 18:265–287, 1982.Google Scholar
  28. [28]
    Flemming Nielson and Hanne Riis Nielson. Two-level semantics and code generation. Theoretical Computer Science, 56(1):59–133, January 1988.Google Scholar
  29. [29]
    Gordon D. Plotkin. Call-by-name, call-by-value and the λ-calculus. Theoretical Computer Science, 1:125–159, 1975.Google Scholar
  30. [30]
    John C. Reynolds. Definitional interpreters for higher-order programming languages. In Proceedings of 25th ACM National Conference, pages 717–740, Boston, 1972.Google Scholar
  31. [31]
    David A. Schmidt. Denotational Semantics: A Methodology for Language Development. Allyn and Bacon, Inc., 1986.Google Scholar
  32. [32]
    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.Google Scholar
  33. [33]
    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.Google Scholar
  34. [34]
    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.Google Scholar
  35. [35]
    Philip Wadler. Comprehending monads. In LFP'90 [23], pages 61–78.Google Scholar
  36. [36]
    Mitchell Wand. Semantics-directed machine architecture. In Proceedings of the Ninth Annual ACM Symposium on Principles of Programming Languages, pages 234–241, January 1982.Google Scholar
  37. [37]
    Mitchell Wand. A short proof of the lexical addressing algorithm. Information Processing Letters, 35:1–5, 1990.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1992

Authors and Affiliations

  1. 1.Department of Computing and Information SciencesKansas State UniversityManhattanUSA

Personalised recommendations