Abstracting control

The last few years have seen a renewed interest in continuations for expressing advanced control structures in programming languages, and new models such as Abstract Continuations have been proposed to capture these dimensions. This article investigates an alternative formulation, exploiting the latent expressive power of the standard continuation-passing style (CPS) instead of introducing yet other new concepts. We build on a single foundation: abstracting control as a hierarchy of continuations, each one modeling a specific language feature as acting on nested evaluation contexts. We show how iterating the continuation-passing conversion allows us to specify a wide range of control behavior. For example, two conversions yield an abstraction of Prolog-style backtracking. A number of other constructs can likewise be expressed in this framework; each is defined independently of the others, but all are arranged in a hierarchy making any interactions between them explicit. This approach preserves all the traditional results about CPS, e.g., its evaluation order independence. Accordingly, our semantics is directly implementable in a call-by-value language such as Scheme or ML. Furthermore, because the control operators denote simple, typable lambda-terms in CPS, they themselves can be statically typed. Contrary to intuition, the iterated CPS transformation does not yield huge results: except where explicitly needed, all continuations beyond the first one disappear due to the extensionality principle (&eegr;-reduction). Besides presenting a new motivation for control operators, this paper also describes an improved conversion into applicative-order CPS. The conversion operates in one pass by performing all administrative reductions at translation time; interestingly, it can be expressed very concisely using the new control operators. The paper also presents some examples of nondeterministic programming in direct style.

[1]  Joseph E. Stoy,et al.  The Congruence of two Programming Language Definitions , 1981, Theor. Comput. Sci..

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

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

[4]  Mitchell Wand,et al.  The mystery of the tower revealed: a non-reflective description of the reflective tower , 1986, LFP '86.

[5]  Karoline Malmkjær,et al.  On Some Semantic Issues in the Reflective Tower , 1989, Mathematical Foundations of Programming Semantics.

[6]  Alfred V. Aho,et al.  The Design and Analysis of Computer Algorithms , 1974 .

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

[8]  Daniel P. Friedman,et al.  Embedding continuations in procedural objects , 1987, TOPL.

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

[10]  Chris Mellish,et al.  Integrating Prolog in the POPLOG Environment , 1984, Implementations of Prolog.

[11]  Matthias Felleisen,et al.  Abstract continuations: a mathematical semantics for handling full jumps , 1988, LISP and Functional Programming.

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

[13]  Olivier Danvy,et al.  Intensions and extensions in a reflective tower , 1988, LISP and Functional Programming.

[14]  Gregory F. Johnson,et al.  Stores and partial continuations as first-class objects in a language and its environment , 1988, POPL '88.

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

[16]  Adrian Tang,et al.  Constructing Call-by-Value Continuation Semantics , 1980, JACM.

[17]  James H. Morris A bonus from van Wijngaarden's device , 1972, CACM.

[18]  Matthias Felleisen,et al.  Control delimiters and their hierarchies , 1990, LISP Symb. Comput..

[19]  Antoni W. Mazurkiewicz,et al.  Proving Algorithms by Tail Functions , 1971, Inf. Control..

[20]  Michael J. Fischer Lambda calculus schemata , 1972 .

[21]  Gerald Jay Sussman,et al.  Lambda: The Ultimate Imperative , 1976 .

[22]  Christopher Strachey,et al.  A theory of programming language semantics , 1976 .

[23]  Matthias Felleisen,et al.  The theory and practice of first-class prompts , 1988, POPL '88.

[24]  Andrew W. Appel,et al.  Continuation-passing, closure-passing style , 1989, POPL '89.

[25]  Mitchell Wand,et al.  The mystery of the tower revealed: A nonreflective description of the reflective tower , 1988, LISP Symb. Comput..

[26]  Olivier Danvy,et al.  A Functional Abstraction of Typed Contexts , 1989 .

[27]  G. F. Johnson GL-a denotational testbed with continuations and partial continuations as first-class objects , 1987, PLDI.

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

[29]  Slocum Miller James,et al.  Multischeme : a parallel processing system based on MIT scheme , 1987 .