Implementing first-class polymorphic delimited continuations by a type-directed selective CPS-transform

We describe the implementation of first-class polymorphic delimited continuations in the programming language Scala. We use Scala's pluggable typing architecture to implement a simple type and effect system, which discriminates expressions with control effects from those without and accurately tracks answer type modification incurred by control effects. To tackle the problem of implementing first-class continuations under the adverse conditions brought upon by the Java VM, we employ a selective CPS transform, which is driven entirely by effect-annotated types and leaves pure code in direct style. Benchmarks indicate that this high-level approach performs competitively.

[1]  Chung-chieh Shan,et al.  Higher-order and Symbolic Computation Manuscript No. a Static Simulation of Dynamic Delimited Control , 2022 .

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

[3]  Kenichi Asai On typing delimited continuations: three new solutions to the printf problem , 2009, High. Order Symb. Comput..

[4]  Amr Sabry,et al.  The essence of compiling with continuations , 1993, PLDI '93.

[5]  Chung-chieh Shan,et al.  Shift control. , 2002, Nursing standard (Royal College of Nursing (Great Britain) : 1987).

[6]  Michael Sperber,et al.  Final shift for call/cc:: direct implementation of shift and reset , 2002, ICFP '02.

[7]  Olivier Danvy Functional Unparsing , 1998, J. Funct. Program..

[8]  Matthias Felleisen,et al.  On the Expressive Power of Programming Languages , 1990, European Symposium on Programming.

[9]  Joe Marshall,et al.  Continuations from generalized stack inspection , 2005, ICFP '05.

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

[11]  Robert Atkey,et al.  Parameterised notions of computation , 2006, J. Funct. Program..

[12]  Andrzej Filinski,et al.  Representing layered monads , 1999, POPL '99.

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

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

[15]  Yukiyoshi Kameyama,et al.  Polymorphic Delimited Continuations , 2007, APLAS.

[16]  Jan Vitek,et al.  Continuations in the Java Virtual Machine , 2007 .

[17]  Olivier Danvy,et al.  On one-pass CPS transformations , 2002, Journal of Functional Programming.

[18]  Christopher Strachey,et al.  Continuations: A Mathematical Semantics for Handling Full Jumps , 2000, High. Order Symb. Comput..

[19]  Martin Odersky,et al.  Scala Actors: Unifying thread-based and event-based programming , 2009, Theor. Comput. Sci..

[20]  Olivier Danvy,et al.  On the static and dynamic extents of delimited continuations , 2005, Sci. Comput. Program..

[21]  Alan Mycroft,et al.  Kilim: Isolation-Typed Actors for Java , 2008, ECOOP.

[22]  Martin Odersky,et al.  Generics of a higher kind , 2008, OOPSLA.

[23]  Andrew W. Appel,et al.  Compiling with Continuations , 1991 .

[24]  Vladimir Lifschitz,et al.  Artificial intelligence and mathematical theory of computation: papers in honor of John McCarthy , 1991 .

[25]  Paul Hudak,et al.  Functional reactive animation , 1997, ICFP '97.

[26]  Cédric Fournet,et al.  The reflexive CHAM and the join-calculus , 1996, POPL '96.

[27]  Hayo Thielecke,et al.  From control effects to typed continuation passing , 2003, POPL '03.

[28]  Amr Sabry,et al.  Delimited dynamic binding , 2006, ICFP '06.

[29]  Gul Agha,et al.  Concurrent programming using actors , 1987 .

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

[31]  William D. Clinger,et al.  Implementation Strategies for First-Class Continuations , 1999, High. Order Symb. Comput..

[32]  Martin Odersky,et al.  Functional Nets , 2000, ESOP.

[33]  Lasse R. Nielsen A Selective CPS Transformation , 2001, MFPS.

[34]  Martin Odersky,et al.  Event-Based Programming Without Inversion of Control , 2006, JMLC.

[35]  Simon L. Peyton Jones,et al.  A monadic framework for delimited continuations , 2007, J. Funct. Program..

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

[37]  Doug Lea,et al.  A Java fork/join framework , 2000, JAVA '00.

[38]  Oleg Kiselyov,et al.  How to remove a dynamic prompt: static and dynamic delimited continuation operators are equally expressible , 2005 .

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

[40]  Richard P. Gabriel The Design of Parallel Programming Languages , 1991, Artificial and Mathematical Theory of Computation.

[41]  Shriram Krishnamurthi,et al.  Embedding Dynamic Dataflow in a Call-by-Value Language , 2006, ESOP.

[42]  Henrik Nilsson,et al.  The Yampa arcade , 2003, Haskell '03.

[43]  Sriram Srinivasan,et al.  A Thread of One's Own , 2006 .

[44]  Yukiyoshi Kameyama,et al.  Typed Dynamic Control Operators for Delimited Continuations , 2008, FLOPS.