Skip to main content Accessibility help
×
Home

Representing Control: a Study of the CPS Transformation

  • Oliver Danvy (a1) and Andrzex Filinski (a2)

Abstract

This paper investigates the transformation of λν-terms into continuation-passing style (CPS). We show that by appropriate η-expansion of Fisher and Plotkin's two-pass equational specification of the CPS transform, we can obtain a static and context-free separation of the result terms into “essential” and “administrative” constructs. Interpreting the former as syntax builders and the latter as directly executable code, We obtain a simple and efficient one-pass transformation algorithm, easily extended to conditional expressions, recursive definitions, and similar constructs. This new transformation algorithm leads to a simpler proof of Plotkin's simulation and indifference results.

We go on to show how CPS-based control operators similar to, more general then, Scheme's call/cc can be naturally accommodated by the new transformation algorithm. To demonstrate the expressive power of these operators, we use them to present an equivalent but even more concise formulation of the efficient CPS transformation algorithm. Finally, we relate the fundamental ideas underlying this derivation to similar concepts from other work on program manipulation; we derive a one-pass CPS transformation of λn-terms; and we outline some promising areas for future research.

Copyright

References

Hide All
Appel, A.W. (1992) Compiling with Continuations. Cambridge University Press.
Bondorf, A. (1991) Automatic autoprojection of higher-order recursive equations. Science of Computer Programming 17 334.
Bondorf, A. and Danvy, O. (1991) Automatic autoprojection of recursive equations with global variables and abstract data types. Science of Computer Programming 16 151195.
Clinger, W. (1984) The Scheme 311 compiler, an excercise in Denotational Semantics. In: Conference Record of the 1984 ACM Symposium on Lisp and Functional Programming, Austin, Texas356364.
Clinger, W. and Rees, J., editors (1991) Revised4 report on the algorithmic language Scheme. LISP Pointers IV(3) 155.
Consel, C. and Danvy, O. (1991 a) Static and dynamic semantics processing. In: Proceedings of the Eighteenth Annual ACM Symposium on Principles of Programming Languages, Orlando, Florida. ACM Press, 1424.
Consel, C. and Danvy, O. (1991b) For a better support of static data flow. In: Proceedings of the Fifth ACM Conference on Functional Programming and Computer Architecture, number 523 in Lecture Notes in Computer Science, Cambridge, Massachusetts, 496519.
Danvy, O. (1989) Programming with tighter control. Special issue of the BIGRE journal: Putting Scheme to Work, (65) 1029.
Danvy, O. (1992) Back to direct style. In: Krieg-Brückner, B., editor, Proceedings of the Fourth European Symposium on Programming, number 582 in Lecture Notes in Computer Science, Rennes, France, 130150.
Danvy, O. and Filinski, A. (1990) Abstracting control. In: Proceedings of the 1990 ACM Conference on Lisp and Functional Programming, Nice, France, 151160.
Danvy, O. and Lawall, J. L. (1992) Back to direct style II: First-class continuations. In: Proceedings of the 1992 ACM Conference on Lisp and Functional Programming, San Fransisco, California.
Duba, B. F., Harper, R., and MacQuuen, D. (1991) Typing first-class continuations in ML. In: Proceedings of the Eighteenth Annual ACM Symposium on Principles of Programming Languages, Orlanda, Florida. ACM Press, 163173.
Felleisen, M. (1988) The theory and practice of first-class prompts. In: Proceedings of the Fifteenth Annual ACM Symposium on Principles of Programming Languages, San Diego, California, 180190.
Felleisen, M., Friedman, D.P., Duba, B., and Merrill, J. (1987a) Beyond continuations. Technical Report 216, Computer Science Department, Indiana University, Bloomington, Indiana.
Felleisen, M., Friedman, D.P., Kohlbecker, E., and Duba, B. (1986) Reasoning with continuations. In: Proceedings of the First Symposium on Logic in Computer Science, Cambridge, Massachusetts. IEEE, 131141.
Felleisen, M., Friedman, D.P., Kohlbecker, E., and Duba, B. (1987b) A syntactic theory of sequential control. Theoretical Computer Science 52(3) 205237.
Felleisen, M.Wand, M., Friedman, D.P. and Duba, B. F. (1988) Abstract continuations: A mathematical semantics for handling full functional jumps. In: Proceedings of the 1988 ACM Conference on Lisp and Functional Programming, Snowbird, Utah, 5262.
Fillnski, A. (1992) Linear continuations. In: Proceedings of the Nineteenth Annual ACM Symposium on Principles of Programming Languages, Albuquerque, New Mexico, ACM Pree, 2738.
Fisher, M. J. (1972) Lambda calculas schemata. In: Proceedings of the ACM Conference on Proving Assertions about Programs. SIGPLAN Notices 71 104109 and SIGACT News 14.
Fradet, P. and Le Métayer, D. (1991) Compilation of functional languages by transformation. ACM Transactions on Programming Languages and Systems 13 2151.
Griffin, T. G. (1990) A formulae-as-types notion of control. In: Proceedings of the Seventeenth Annual ACM Symposium on Principles of Programming Languages, San Franscisco, California. ACM Press, 4758.
Griffin, R. E. and Grisworld, M. T. (1983) The Icon Programming Language. Prentice-Hall.
Harber, B. and Lillibridge, M. (1992) Polymorphic type assignment and CPS conversion. In: Danvy, O. and Talcott, C. L., editors, Proceedings of the ACM SIGPLAN Workshop on Continuations, San Franscisco, California. Technical report STAN-CS-92-1426, Standford University.
Jones, N. D., Sestoft, P., and Søndergaard, H. (1989) MIX: A self-applicable partial evaluator for experiments in compiler generation. LISP and Symbolic Computation 2(1) 950.
Mellish, C. and Hardy, S. (1984) Integrating Prolog in the POPLOG environment. In: Cambell, J. A., editor, Implements of PROLOG, Ellis Horwood, 147162.
Milner, R., Tofte, M., and Harper, R. (1990) The definition of standard ML. The MIT Press.
Moggi, E. (1989) Computational lambda-calculas and monads. In: Proceedings of the Fourth Annual Symposium on Logic in Computer Science, Pacific Grove, California, IEEE, 1423.
Murthy, C. R. (1990) Ectracting Constructive Content from Classical Proofs. PhD thesis, Department of Computer Science, Cornell University.
Murthy, C. R. (1992) Control operators, hierarchies, and pseudo-classical type systems: A-translation at work. In: Danvy, O. and Talcott, C. L., editors, Proceedings of the ACM SIGPLAN Work-shop on Continuations, San Fransisco, California. Technical report STAN-CS-92-1426, Standford University.
Nielson, F. (1989) Two-level semantics and abstract interpretaion. Theoretical Computer Science 69(2) 117242.
Nielson, F. and Nielson, H. R. (1988) Two-level semantics and code generation. Theoretical Computer Science 56(1) 59133.
Plotkin, G. D. (1975) Call-by-name, call-by-value and the λ-calculas. Theoretical Computer Science 1 125159.
Reynolds, J. C. (1972) Definitional interpreters for higher-order programming languages. In: Proceedings of 25th ACM National Conference, Boston, 717740.
Riecke, J. G. (1989) Should a funcion continue? Master's thesis, Department of Electrical Engineering and Computer Science, Massachusetts Institute of Technology, Cambridge, Massachusetts.
Sabry, A. and Felleisen, M. (1922) Reasoning about programs in continuation-passing style. In: Proceedings of the 1992 ACM Conference on Lisp and Functional Programming, San Fransisco, Calfornia.
Shivers, O. (1991) The semantics of Scheme control-flow analysis. In: Hudak, P. and Jones, N. D.., editors, Symposium on Partial Evaluation and Semantics-Based Program Manipulation. SIGPLAN Notices 26 (9), ACM Press, New Haven, Connecticut. 190198.
Sitaram, D. and Felleisen, M. (1990) Reasoning with continuations II: Full abstraction for models of control. In: Proceedings of the 1900 ACM on Lisp and Functional Programming, Nice, France, 161175.
Steele, G. L. Jr (1978) Rabbit: A Compiler for Scheme. Technical Report A I-TR-474, Artificial Intelligence Laboratory, Massachusetts Institute of Technology, Cambridge, Massachusetts.
Wadler, P. (1992) The essence of functional programming. In: Proceedings of the Nineteenth Annual ACM Symposium on Principles of Programming Languages, Albuquerque, New Mexico. ACM Press, 114.
Wand, M. (1991) Correctness of procedure representations in higher-order assembly language. In: Brrokes, S., Main, M., Melton, A., and Schmidt, D., editors, Mathematical Foundations of Programming Semantics, volume 598 of Lecture Notes in Computer Science, Pittsburgh, Pennsylvania. 7th International Conference, 294311.

Related content

Powered by UNSILO

Representing Control: a Study of the CPS Transformation

  • Oliver Danvy (a1) and Andrzex Filinski (a2)

Metrics

Altmetric attention score

Full text views

Total number of HTML views: 0
Total number of PDF views: 0 *
Loading metrics...

Abstract views

Total abstract views: 0 *
Loading metrics...

* Views captured on Cambridge Core between <date>. This data will be updated every 24 hours.

Usage data cannot currently be displayed.