Advertisement

Typing Coroutines

  • Konrad Anton
  • Peter Thiemann
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 6546)

Abstract

A coroutine is a programming construct between function and thread. It behaves like a function that can suspend itself arbitrarily often to yield intermediate results and to get new inputs before returning a result. This facility makes coroutines suitable for implementing generator abstractions.

Languages that support coroutines are often untyped or they use trivial types for coroutines. This work supplies the first type system with dedicated support for coroutines. The type system is based on the simply-typed lambda calculus extended with effects that describe control transfers between coroutines.

Keywords

Type System Operational Semantic Return Type Store Typing Programming Construct 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Belsnes, D., Østvold, B.M.: Mixing threads and coroutines (2005), submitted to FOSSACS 2005, bjarte@nr.noGoogle Scholar
  2. 2.
    Berdine, J., O’Hearn, P., Reddy, U., Thielecke, H.: Linear continuation-passing. Higher-Order and Symbolic Computation 15(2-3), 181–208 (2002)CrossRefzbMATHGoogle Scholar
  3. 3.
    Blazevic, M.: monad-coroutine: Coroutine monad transformer for suspending and resuming monadic computations (2010), http://hackage.haskell.org/package/monad-coroutine
  4. 4.
    Conway, M.E.: Design of a separable transition-diagram compiler. Comm. ACM 6(7), 396–408 (1963)CrossRefzbMATHGoogle Scholar
  5. 5.
    Dahl, O.J., Myrhaug, B., Nygaard, K.: SIMULA 67 Common Base Language. Norwegian Computing Center, Oslo (1970) (revised version 1984)Google Scholar
  6. 6.
    Harper, R., Duba, B.F., MacQueen, D.: Typing first-class continuations in ML. In: Proc.  1991 ACM Symp. POPL. ACM Press, Orlando (1991)Google Scholar
  7. 7.
    Haynes, C.T., Friedman, D.P., Wand, M.: Obtaining coroutines with continuations. Computer Languages 11(3), 143–153 (1986)CrossRefzbMATHGoogle Scholar
  8. 8.
    Knuth, D.E.: Fundamental Algorithms, The Art of Computer Programming, 2nd edn., vol. 1. Addison-Wesley, Reading (1968)zbMATHGoogle Scholar
  9. 9.
    Kristensen, B.B., Pedersen, B.M., Madsen, O.L., Nygaard, K.: Coroutine sequencing in BETA. In: Proc. of 21st Annual Hawaii International Conference on Software Track, pp. 396–405. IEEE Computer Society Press, Los Alamitos (1988)Google Scholar
  10. 10.
    Laird, J.: A calculus of coroutines. In: Díaz, J., Karhumäki, J., Lepistö, A., Sannella, D. (eds.) ICALP 2004. LNCS, vol. 3142, pp. 882–893. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  11. 11.
    Liskov, B.: CLU reference manual. LNCS, vol. 114. Springer, Heidelberg (1981)zbMATHGoogle Scholar
  12. 12.
    Marlin, C.D.: Coroutines: a programming methodology, a language design and an implementation. Springer, Heidelberg (1980)CrossRefzbMATHGoogle Scholar
  13. 13.
    Microsoft Corp.: C# Version 2.0 Specification (2005), http://msdn.microsoft.com/en-US/library/618ayhy6v=VS.80.aspx
  14. 14.
    de Moura, A.L., Ierusalimschy, R.: Revisiting coroutines. ACM Trans. Program. Lang. Syst. 31(2), 1–31 (2009)CrossRefGoogle Scholar
  15. 15.
    de Moura, A.L., Rodriguez, N., Ierusalimschy, R.: Coroutines in Lua. Journal of Universal Computer Science 10, 925 (2004)Google Scholar
  16. 16.
    Peyton Jones, S. (ed.): Haskell 98 Language and Libraries, The Revised Report. Cambridge University Press, Cambridge (2003)zbMATHGoogle Scholar
  17. 17.
    Van Rossum, G., Eby, P.: PEP 342 – coroutines via enhanced generators (2005), http://www.python.org/dev/peps/pep-0342/
  18. 18.
    Wang, A., Dahl, O.J.: Coroutine sequencing in a block structured environment. BIT Numerical Mathematics 11(4), 425–449 (1971), http://www.springerlink.com/content/g870vkxx22861w50 CrossRefzbMATHGoogle Scholar
  19. 19.
    Wirth, N.: Programming in Modula-2. Springer, Heidelberg (1982)CrossRefzbMATHGoogle Scholar
  20. 20.
    Wright, A., Felleisen, M.: A syntactic approach to type soundness. Information and Computation 115(1), 38–94 (1994)MathSciNetCrossRefzbMATHGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2011

Authors and Affiliations

  • Konrad Anton
    • 1
  • Peter Thiemann
    • 1
  1. 1.Institut für InformatikUniversität FreiburgGermany

Personalised recommendations