research-article

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

Authors Info & Claims
Published:31 August 2009Publication History

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

implementingfirst-classpolymorphicdelimitedcontinuationsbya.mp4

References

  1. Agha, Gul, and Carl Hewitt. 1987. Concurrent programming using actors. In Object-oriented concurrent programming, 37--53. MIT Press, Cambridge, MA, USA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Appel, Andrew W. 1992. Compiling with continuations. Cambridge University Press, New York, NY, USA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Appel, Andrew W., and Trevor Jim. 1989. Continuation-passing, closurepassing style. In Proc. POPL'89, 293--302. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. 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 ScholarGoogle Scholar
  5. Asai, Kenichi, and Yukiyoshi Kameyama. 2007. Polymorphic delimited continuations. In Proc. APLAS'07, vol. 4807 of LNCS, 91--108. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Atkey, Robert. 2006. Parameterised notions of computation. In Proc. MSFP'06, 31--45. Electronic Workshops in Computing, British Computer Society. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. 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 ScholarGoogle Scholar
  8. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  10. Cooper, Gregory H., and Shriram Krishnamurthi. 2006. Embedding dynamic dataflow in a call-by-value language. In Proc. ESOP'06, 294--308. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Courtney, Antony, Henrik Nilsson, and John Peterson. 2003. The Yampa arcade. In Proc. ACM SIGPLAN workshop on Haskell, 7--18. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Danvy, Olivier. 1998. Functional unparsing. J. Funct. Program. 8(06):621--625. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Danvy, Olivier, and Andrzej Filinski. 1989. A Functional Abstraction of Typed Contexts. Tech. Rep., DIKU University of Copenhagen, Denmark.Google ScholarGoogle Scholar
  14. ---. 1990. Abstracting control. In Proc. LFP'90, 151--160. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. ---. 1992. Representing Control: A Study of the CPS Transformation. Mathematical Structures in Computer Science 2(4):361--391.Google ScholarGoogle ScholarCross RefCross Ref
  16. Danvy, Olivier, Kevin Millikin, and Lasse R. Nielsen. 2007. On one-pass CPS transformations. J. Funct. Program. 17(6):793--812. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Dragos, Iulian, Antonio Cunei, and Jan Vitek. 2007. Continuations in the Java Virtual Machine. In Proc. ICOOOLPS'07.Google ScholarGoogle Scholar
  18. Dyvbig, R. Kent, Simon Peyton-Jones, and Amr Sabry. 2007. A monadic framework for delimited continuations. J. Funct. Program. 17(6):687--730. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Elliott, Conal, and Paul Hudak. 1997. Functional reactive animation. In Proc. ICFP'97. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Felleisen, Matthias. 1991. On the expressive power of programming languages. Science of Computer Programming 17(1-3):35--75. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  22. Felleisen, Mattias. 1988. The theory and practice of first-class prompts. In Proc. POPL-88, 180--190. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Filinski, Andrzej. 1994. Representing monads. In Proc. POPL'94, 446--457. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. ---. 1999. Representing layered monads. In Proc. POPL'99, 175--188. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  26. Fournet, Cedric, and Georges Gonthier. 1996. The reflexive CHAM and the join-calculus. In Proc. POPL'96, 372--385. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  28. Gasbichler, Martin, and Michael Sperber. 2002. Final shift for call/cc:: direct implementation of shift and reset. In Proc. ICFP'02, 271--282. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Haller, Philipp, and Martin Odersky. 2006. Event-based programming without inversion of control. In Proc. JMLC'06, vol. 4228 of LNCS, 4--22. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. ---. 2009. Scala actors: Unifying thread-based and event-based programming. Theor. Comput. Sci 410(2-3):202--220. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Kameyama, Yukiyoshi, and Takuo Yonezawa. 2008. Typed dynamic control operators for delimited continuations. In Proc. FLOPS'08, vol. 4989 of LNCS, 239--254. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. 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 ScholarGoogle Scholar
  33. ---. 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 ScholarGoogle Scholar
  34. Kiselyov, Oleg, Chung-chieh Shan, and Amr Sabry. 2006. Delimited dynamic binding. In Proc. ICFP'06, 26--37. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Lea, Doug. 2000. A Java fork/join framework. In Proc. ACM Java Grande, 36--43. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Moors, Adriaan, Frank Piessens, and Martin Odersky. 2008. Generics of a higher kind. In Proc. OOPSLA'08, 423--438. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. 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 ScholarGoogle Scholar
  38. Nielsen, Lasse R. 2001. A selective CPS transformation. Tech. Rep. RS-01-30, BRICS, Department of Computer Science, Aarhus University.Google ScholarGoogle Scholar
  39. Odersky, Martin. 2000. Functional Nets. In Proc. European Symposium on Programming Languages and Systems, 1--25. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Pettyjohn, Greg, John Clements, Joe Marshall, Shriram Krishnamurthi, and Matthias Felleisen. 2005. Continuations from generalized stack inspection. SIGPLAN Not. 40(9):216--227. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. 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 ScholarGoogle Scholar
  42. Rose, John. 2008. JSR 292: Supporting dynamically typed languages on the Java platform. http://jcp.org/en/jsr/detail?id=292.Google ScholarGoogle Scholar
  43. Shan, Chung-chieh. 2004. Shift to control. In Proc. ACM SIGPLAN workshop on Scheme and functional programming, 99--107.Google ScholarGoogle Scholar
  44. ---. 2007. A static simulation of dynamic delimited control. Higher-Order and Symbolic Computation 20(4):371--401. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. Srinivasan, Sriram. 2006. A thread of one's own. In New horizons in compilers workshop, hipc, bangalore.Google ScholarGoogle Scholar
  46. Srinivasan, Sriram, and Alan Mycroft. 2008. Kilim: Isolation-typed actors for Java. In Proc. ECOOP'08, 104--128. Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  48. Thielecke, Hayo. 2003. From control effects to typed continuation passing. In Proc. POPL'03, 139--149. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

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

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in

    Full Access

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader
    About Cookies On This Site

    We use cookies to ensure that we give you the best experience on our website.

    Learn more

    Got it!