Abstract
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.
Supplemental Material
References
- Agha, Gul, and Carl Hewitt. 1987. Concurrent programming using actors. In Object-oriented concurrent programming, 37--53. MIT Press, Cambridge, MA, USA. Google Scholar
Digital Library
- Appel, Andrew W. 1992. Compiling with continuations. Cambridge University Press, New York, NY, USA. Google Scholar
Digital Library
- Appel, Andrew W., and Trevor Jim. 1989. Continuation-passing, closurepassing style. In Proc. POPL'89, 293--302. Google Scholar
Digital Library
- Asai, Kenichi. 2007. On typing delimited continuations: Three new solutions to the printf problem. Tech. Rep. OCHA-IS 07-1, Department of Information Science, Ochanomizu University, Tokyo, Japan. Available from: http://pllab.is.ocha.ac.jp/~asai/papers/.Google Scholar
- Asai, Kenichi, and Yukiyoshi Kameyama. 2007. Polymorphic delimited continuations. In Proc. APLAS'07, vol. 4807 of LNCS, 91--108. Google Scholar
Digital Library
- Atkey, Robert. 2006. Parameterised notions of computation. In Proc. MSFP'06, 31--45. Electronic Workshops in Computing, British Computer Society. Google Scholar
Digital Library
- Balat, Vincent, and Olivier Danvy. 1997. Strong normalization by run-time code generation. Tech. Rep. BRICS RS-97-43, Department of Computer Science, University of Aarhus, Denmark.Google Scholar
- Biernacki, Dariusz, Olivier Danvy, and Chung-chieh Shan. 2006. On the static and dynamic extents of delimited continuations. Science of Computer Programming 60(3):274--297. Google Scholar
Digital Library
- Clinger, William D., Anne H. Hartheimer, and Eric M. Ost. 1999. Implementation Strategies for First-Class Continuations. Higher-Order and Symbolic Computation 12(1):7--45. Google Scholar
Digital Library
- Cooper, Gregory H., and Shriram Krishnamurthi. 2006. Embedding dynamic dataflow in a call-by-value language. In Proc. ESOP'06, 294--308. Google Scholar
Digital Library
- Courtney, Antony, Henrik Nilsson, and John Peterson. 2003. The Yampa arcade. In Proc. ACM SIGPLAN workshop on Haskell, 7--18. Google Scholar
Digital Library
- Danvy, Olivier. 1998. Functional unparsing. J. Funct. Program. 8(06):621--625. Google Scholar
Digital Library
- Danvy, Olivier, and Andrzej Filinski. 1989. A Functional Abstraction of Typed Contexts. Tech. Rep., DIKU University of Copenhagen, Denmark.Google Scholar
- ---. 1990. Abstracting control. In Proc. LFP'90, 151--160. Google Scholar
Digital Library
- ---. 1992. Representing Control: A Study of the CPS Transformation. Mathematical Structures in Computer Science 2(4):361--391.Google Scholar
Cross Ref
- Danvy, Olivier, Kevin Millikin, and Lasse R. Nielsen. 2007. On one-pass CPS transformations. J. Funct. Program. 17(6):793--812. Google Scholar
Digital Library
- Dragos, Iulian, Antonio Cunei, and Jan Vitek. 2007. Continuations in the Java Virtual Machine. In Proc. ICOOOLPS'07.Google Scholar
- Dyvbig, R. Kent, Simon Peyton-Jones, and Amr Sabry. 2007. A monadic framework for delimited continuations. J. Funct. Program. 17(6):687--730. Google Scholar
Digital Library
- Elliott, Conal, and Paul Hudak. 1997. Functional reactive animation. In Proc. ICFP'97. Google Scholar
Digital Library
- Felleisen, Matthias. 1991. On the expressive power of programming languages. Science of Computer Programming 17(1-3):35--75. Google Scholar
Digital Library
- Felleisen, Matthias, Mitch Wand, Daniel Friedman, and Bruce Duba. 1988. Abstract continuations: a mathematical semantics for handling full jumps. In Proc. LFP'88, 52--62. Google Scholar
Digital Library
- Felleisen, Mattias. 1988. The theory and practice of first-class prompts. In Proc. POPL-88, 180--190. Google Scholar
Digital Library
- Filinski, Andrzej. 1994. Representing monads. In Proc. POPL'94, 446--457. Google Scholar
Digital Library
- ---. 1999. Representing layered monads. In Proc. POPL'99, 175--188. Google Scholar
Digital Library
- Flanagan, Cormac, Amr Sabry, Bruce F. Duba, and Matthias Felleisen. 1993. The essence of compiling with continuations. In Proc. PLDI'93, vol. 28(6), 237--247. Google Scholar
Digital Library
- Fournet, Cedric, and Georges Gonthier. 1996. The reflexive CHAM and the join-calculus. In Proc. POPL'96, 372--385. Google Scholar
Digital Library
- Gabriel, Richard P. 1991. The design of parallel programming languages. In Artificial intelligence and mathematical theory of computation: papers in honor of john mccarthy, 91--108. Academic Press Professional, San Diego, CA, USA. Google Scholar
Digital Library
- Gasbichler, Martin, and Michael Sperber. 2002. Final shift for call/cc:: direct implementation of shift and reset. In Proc. ICFP'02, 271--282. Google Scholar
Digital Library
- Haller, Philipp, and Martin Odersky. 2006. Event-based programming without inversion of control. In Proc. JMLC'06, vol. 4228 of LNCS, 4--22. Google Scholar
Digital Library
- ---. 2009. Scala actors: Unifying thread-based and event-based programming. Theor. Comput. Sci 410(2-3):202--220. Google Scholar
Digital Library
- Kameyama, Yukiyoshi, and Takuo Yonezawa. 2008. Typed dynamic control operators for delimited continuations. In Proc. FLOPS'08, vol. 4989 of LNCS, 239--254. Google Scholar
Digital Library
- Kiselyov, Oleg. 2005. How to remove a dynamic prompt: static and dynamic delimited continuation operators are equally expressible. Tech. Rep. TR611, Department of Computer Science, Indiana University.Google Scholar
- ---. 2007. Genuine shift/reset in haskell98. Announcement and explanations posted on the Haskell mailing list on 12/12/2007. Implementation available from: http://okmij.org/ftp/Haskell/ShiftResetGenuine.hs.Google Scholar
- Kiselyov, Oleg, Chung-chieh Shan, and Amr Sabry. 2006. Delimited dynamic binding. In Proc. ICFP'06, 26--37. Google Scholar
Digital Library
- Lea, Doug. 2000. A Java fork/join framework. In Proc. ACM Java Grande, 36--43. Google Scholar
Digital Library
- Moors, Adriaan, Frank Piessens, and Martin Odersky. 2008. Generics of a higher kind. In Proc. OOPSLA'08, 423--438. Google Scholar
Digital Library
- Nielsen, Anders Bach. 2008. Scala compiler phase and plug-in initialization. Available from: http://lampsvn.epfl.ch/svn-repos/scala/lamp-sip/compiler-phase-init/sip-00002.xhtml.Google Scholar
- Nielsen, Lasse R. 2001. A selective CPS transformation. Tech. Rep. RS-01-30, BRICS, Department of Computer Science, Aarhus University.Google Scholar
- Odersky, Martin. 2000. Functional Nets. In Proc. European Symposium on Programming Languages and Systems, 1--25. Google Scholar
Digital Library
- Pettyjohn, Greg, John Clements, Joe Marshall, Shriram Krishnamurthi, and Matthias Felleisen. 2005. Continuations from generalized stack inspection. SIGPLAN Not. 40(9):216--227. Google Scholar
Digital Library
- Rompf, Tiark. 2007. Design and implementation of a programming language for concurrent interactive systems. Master's thesis, Institute of Software Technology and Programming Languages, University of Lubeck, Germany. Available from: http://vodka.nachtlicht-media.de/docs.html.Google Scholar
- Rose, John. 2008. JSR 292: Supporting dynamically typed languages on the Java platform. http://jcp.org/en/jsr/detail?id=292.Google Scholar
- Shan, Chung-chieh. 2004. Shift to control. In Proc. ACM SIGPLAN workshop on Scheme and functional programming, 99--107.Google Scholar
- ---. 2007. A static simulation of dynamic delimited control. Higher-Order and Symbolic Computation 20(4):371--401. Google Scholar
Digital Library
- Srinivasan, Sriram. 2006. A thread of one's own. In New horizons in compilers workshop, hipc, bangalore.Google Scholar
- Srinivasan, Sriram, and Alan Mycroft. 2008. Kilim: Isolation-typed actors for Java. In Proc. ECOOP'08, 104--128. Google Scholar
Digital Library
- Strachey, Christopher, and Christopher P.Wadsworth. 2000. Continuations: A mathematical semantics for handling full jumps. Higher-Order and Symbolic Computation 13(1):135--152. Google Scholar
Digital Library
- Thielecke, Hayo. 2003. From control effects to typed continuation passing. In Proc. POPL'03, 139--149. Google Scholar
Digital Library
Index Terms
Implementing first-class polymorphic delimited continuations by a type-directed selective CPS-transform






Comments