Back to direct style II: first-class continuations

We continue to investigate the direct-style transformation by extending it to programs requiring call-with-current-continuation (a.k.a. call/cc). The direct style (DS) and the continuation-passing style (CPS) transformations form a Galois connection. This pair of functions has a place in the programmer's toolbox—yet we are not aware of the existence of any other DS transformer. Starting from our DS transformer towards pure, call-by-value functional terms (Scheme), we extend it with a counting analysis to detect non-canonical occurrences of a continuation. The declaration of such a continuation is translated into a call/cc and its application into the application of the corresponding first-class continuation We also present staged versions of the DS and of the CPS transformations, where administrative reductions are separated from the actual translation, and where the actual translations are carried out by local, structure-preserving rewriting rules. These staged transformations are used to prove the Galois continuation. Together, the CPS and the DS transformations enlarge the class of programs that can be manipulated on a semantic basis. We illustrate this point with partial evaluation, by specializing a Scheme program with respect to a static part of its input. The program uses coroutines. This illustration achieves a first: a static coroutine is executed statically and its computational content is inlined in the residual program.

[1]  Paul Hudak,et al.  ORBIT: an optimizing compiler for scheme , 1986, SIGPLAN '86.

[2]  John Darlington,et al.  A Transformation System for Developing Recursive Programs , 1977, J. ACM.

[3]  Mitchell Wand,et al.  Essentials of programming languages , 2008 .

[4]  Jr. Guy L. Steele,et al.  Rabbit: A Compiler for Scheme , 1978 .

[5]  Joseph E. Stoy,et al.  Denotational Semantics: The Scott-Strachey Approach to Programming Language Theory , 1981 .

[6]  Michael J. Fischer,et al.  Lambda-calculus schemata , 1993, LISP Symb. Comput..

[7]  Nevin Heintze,et al.  ML Partial Evaluation Using Set-Based Analysis , 1994 .

[8]  Christian Queinnec,et al.  A dynamic extent control operator for partial continuations , 1991, POPL '91.

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

[10]  Andrzej Filinski Declarative Continuations: an Investigation of Duality in Programming Language Semantics , 1989, Category Theory and Computer Science.

[11]  Chetan R. Murthy An evaluation semantics for classical proofs , 1991, [1991] Proceedings Sixth Annual IEEE Symposium on Logic in Computer Science.

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

[13]  Olivier Danvy,et al.  Static and dynamic semantics processing , 1991, POPL '91.

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

[15]  Peter Sestoft,et al.  Partial evaluation and automatic program generation , 1993, Prentice Hall international series in computer science.

[16]  Andrzej Filinski,et al.  Representing monads , 1994, POPL '94.

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

[18]  Alain Deutsch,et al.  On determining lifetime and aliasing of dynamically allocated data in higher-order functional specifications , 1989, POPL '90.

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

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

[21]  Carolyn L. Taylor The Essence of Rum: A Theory of the Intensional and Extensional Aspects of Lisp-Type Computation, , 1985 .

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

[23]  Olivier Danvy,et al.  Abstracting control , 1990, LISP and Functional Programming.

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

[25]  Olivier Danvy,et al.  Tutorial notes on partial evaluation , 1993, POPL '93.

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

[27]  Amr Sabry,et al.  Is continuation-passing useful for data flow analysis? , 1994, PLDI '94.

[28]  David A. Schmidt,et al.  Calois Connections and Computer Science Applications , 1985, CTCS.

[29]  Mitchell Wand,et al.  A scheme for a higher-level semantic algebra , 1986 .

[30]  Robert Hieb,et al.  Continuations and concurrency , 1990, PPOPP '90.

[31]  Mitchell Wand,et al.  Continuations and coroutines , 1984, LFP '84.

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

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

[34]  Charles Consel,et al.  A tour of Schism: a partial evaluation system for higher-order applicative languages , 1993, PEPM '93.

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

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

[37]  John C. Reynolds,et al.  The discoveries of continuations , 1993, LISP Symb. Comput..

[38]  Robert Hieb,et al.  The Revised Report on the Syntactic Theories of Sequential Control and State , 1992, Theor. Comput. Sci..

[39]  Matthias Felleisen,et al.  A Syntactic Theory of Sequential Control , 1987, Theor. Comput. Sci..

[40]  D. H. Bartley,et al.  Revised4 report on the algorithmic language scheme , 1991, LIPO.

[41]  Pierre Jouvelot,et al.  Reasoning about continuations with control effects , 1989, PLDI '89.

[42]  Olivier Danvy,et al.  For a Better Support of Static Data Flow , 1991, FPCA.

[43]  Tony Hoare,et al.  Hierarchical Program Structures , 1972 .

[44]  Richard Andrews Kelsey,et al.  Compilation by program transformation , 1989 .

[45]  Charles Consel,et al.  Binding time analysis for high order untyped functional languages , 1990, LISP and Functional Programming.