Abstract
This article advocates the revival of coroutines as a convenient general control abstraction. After proposing a new classification of coroutines, we introduce the concept of full asymmetric coroutines and provide a precise definition for it through an operational semantics. We then demonstrate that full coroutines have an expressive power equivalent to one-shot continuations and one-shot delimited continuations. We also show that full asymmetric coroutines and one-shot delimited continuations have many similarities, and therefore present comparable benefits. Nevertheless, coroutines are easier implemented and understood, especially in the realm of procedural languages.
- Adya, A., Howell, J., Theimer, M., Bolosky, W. J., and Doucer, J. R. 2002. Cooperative task management without manual stack management. In Proceedings of the USENIX Annual Technical Conference. USENIX. Google Scholar
Digital Library
- Behren, R., Condit, J., and Brewer, E. 2003. Why events are a bad idea (for high-concurrency servers). In Proceedings of the 9th Workshop on Hot Topics in Operating Systems (HotOS IX). Google Scholar
Digital Library
- Birtwistle, G., Dahl, O.-J., Myhrhaug, B., and Nygaard, K. 1980. Simula Begin. Studentlitteratur, Sweden. Google Scholar
Digital Library
- Bruggeman, C., Waddell, O., and Dybvig, R. 1996. Representing control in the presence of one-shot continuations. In Proceedings of the ACM SIGPLAN'96 Conference on Programming Language Design and Implementation (PLDI'96). ACM, 99--107. SIGPLAN Not. 31, 5. Google Scholar
Digital Library
- Clocksin, W. and Mellish, C. 1981. Programming in Prolog. Springer. Google Scholar
Digital Library
- Conway, D. 2000. Rfc 31: Subroutines: Co-routines. http://dev.perl.org/perl6/rfc/31.html.Google Scholar
- Conway, M. 1963. Design of a separable transition-diagram compiler. Commun. ACM 6, 7, 396--408. Google Scholar
Digital Library
- Dahl, O.-J., Dijkstra, E. W., and Hoare, C. A. R. 1972. Hierarchical program structures. In Structured Programming, 2nd ed. Academic Press, London. Google Scholar
Digital Library
- Danvy, O. and Filinski, A. 1990. Abstracting control. In Proceedings of the ACM Conference on LISP and Functional Programming. ACM, 151--160. Google Scholar
Digital Library
- Dybvig, R. and Hieb, R. 1989. Engines from continuations. Comput. Lang. 14, 2, 109--123. Google Scholar
Digital Library
- Felleisen, M. 1985. Transliterating Prolog into Scheme. Tech. rep. 182, Indiana University.Google Scholar
- Felleisen, M. 1988. The theory and practice of first-class prompts. In Proceedings of the 15th ACM Symposium on Principles of Programming Languages (POPL'88). ACM, 180--190. Google Scholar
Digital Library
- Felleisen, M. 1990. On the expressive power of programming languages. In Proceedings of the 3rd European Symposium on Programming (ESOP'90), 134--151. Google Scholar
Digital Library
- Felleisen, M. and Friedman, D. 1986. Control operators, the SECD-machine, and the λ-calculus. In Formal Description of Programming Concepts-III, M. Wirsing, Ed. North-Holland, 193--217.Google Scholar
- Griswold, R. and Griswold, M. 1983. The Icon Programming Language. Prentice-Hall, NJ. Google Scholar
Digital Library
- Harper, R., Duba, B., Harper, R., and MacQueen, D. 1991. Typing first-class continuations in ML. In Proceedings of the 18th ACM Symposium on Principles of Programming Languages (POPL'91). ACM, 163--173. Google Scholar
Digital Library
- Haynes, C. T. 1987. Logic continuations. J. Logic Program. 4, 157--176. Google Scholar
Digital Library
- Haynes, C. T. and Friedman, D. 1987a. Abstracting timed preemption with engines. J. Comput. Lang. 12, 2, 109--121. Google Scholar
Digital Library
- Haynes, C. T., Friedman, D., and Wand, M. 1986. Obtaining coroutines with continuations. Comput. Lang. 11, 3/4, 143--153. Google Scholar
Digital Library
- Haynes, C. T. and Friedman, D. P. 1987b. Embedding continuations in procedural objects. ACM Trans. Progam. Lang. Syst. 9, 4, 582--598. Google Scholar
Digital Library
- Hieb, R. and Dybvig, R. 1990. Continuations and concurrency. In Proceedings of the 2nd ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming. ACM, 128--136. Google Scholar
Digital Library
- Hieb, R., Dybvig, R., and Anderson III, C. W. 1994. Subcontinuations. Lisp Symbolic Comput. 7, 1, 83--110. Google Scholar
Digital Library
- Ierusalimschy, R. 2003. Programming in Lua. Lua.org, Rio de Janeiro, Brazil. Google Scholar
Digital Library
- Ierusalimschy, R. and de Moura, A. L. 2008. Some proofs about coroutines. Monografias em Ciẽncia da Computação 04/08, PUC-Rio, Rio de Janeiro, Brazil.Google Scholar
- Ierusalimschy, R., Figueiredo, L., and Celes, W. 1996. Lua—An extensible extension language. Softw. Pract. & Exper. 26, 6, 635--652. Google Scholar
Digital Library
- Johnson, G. and Duggan, D. 1988. Stores and partial continuations as first-class objects in a language and its environment. In Proceedings of the 15th ACM Symposium on Principles of Programming Languages (POPL'88). ACM. Google Scholar
Digital Library
- Kelsey, R., Clinger, W., and J. Rees, e. 1998. Revised5 report on the algorithmic language Scheme. Higher-Order Symbolic Comput. 11, 1, 7--105. Google Scholar
Digital Library
- Knuth, D. E. 1968. The Art of Computer Programming, Volume 1, Fundamental Algorithms. Addison-Wesley, Reading, MA.Google Scholar
- Kumar, S., Bruggeman, C., and Dybvig, R. 1998. Threads yield continuations. Lisp Symbolic Comput. 10, 3, 223--236. Google Scholar
Digital Library
- Liskov, B., Snyder, A., Atkinson, R., and Schaffert, C. 1977. Abstraction mechanisms in CLU. Commun. ACM 20, 8 (Aug.), 564--576. Google Scholar
Digital Library
- Marlin, C. D. 1980. Coroutines: A Programming Methodology, a Language Design and an Implementation. Lecture Notes in Computer Science, vol. 95, Springer. Google Scholar
Digital Library
- Moody, K. and Richards, M. 1980. A coroutine mechanism for BCPL. Softw. Pract. & Exper. 10, 10, 765--771.Google Scholar
Cross Ref
- Moura, A., Rodriguez, N., and Ierusalimschy, R. 2004. Coroutines in Lua. J. Universal Comput. Sci. 10, 7, 910--925.Google Scholar
- Murer, S., Omohundro, S., Stoutamire, D., and Szyperski, C. 1996. Iteration abstraction in Sather. ACM Trans. Progam. Lang. Syst. 18, 1, 1--15. Google Scholar
Digital Library
- Pauli, W. and Soffa, M. L. 1980. Coroutine behaviour and implementation. Softw, Pract. & Exper. 10, 3, 189--204.Google Scholar
- Queinnec, C. and Serpette, B. 1991. A dynamic extent control operator for partial continuations. In Proceedings of the 18th ACM Symposium on Principles of Programming Languages (POPL'91). ACM, 174--184. Google Scholar
Digital Library
- Richter, J. 1997. Advanced Windows, 3rd ed. Microsoft Press, Redmond, WA. Google Scholar
Digital Library
- Schemenauer, N., Peters, T., and Hetland, M. 2001. PEP 255: Simple generators. http://www.python.org/peps/pep-0255.html.Google Scholar
- Serrano, M., Boussinot, F., and Serpette, B. 2004. Scheme fair threads. In Proceedings of the 6th SIGPLAN International Congress on Principles and Practice of Declarative Programming (PPDP), 203--214. Google Scholar
Digital Library
- Sitaram, D. 1993. Handling control. In Proceedings of the ACM SIGPLAN'93 Confrence on Programming Language Design and Implementation (PLDI'93). ACM, SIGPLAN Not. 28, 6. Google Scholar
Digital Library
- Sitaram, D. 1994. Models of control and their implications for progamming language design. Ph.D. thesis, Rice University. Google Scholar
Digital Library
- Springer, G. and Friedman, D. 1989. Scheme and the Art of Programming. MIT Press, Cambridge, MA. Google Scholar
Digital Library
- Tismer, C. 2000. Continuations and stackless Python. In Proceedings of the 8th International Python Conference. Arlington, VA. http://www.python.org/workshops/2000-01/proceedings.html.Google Scholar
- Wand, M. 1980. Continuation-Based multiprocessing. In Proceedings of the Lisp Conference. ACM, 19--28. Reprinted in Higher-Order Symbolic Comput. 12, 3, 285--299, 1999. Google Scholar
Digital Library
- Wand, M. and Vaillancourt, D. 2004. Relating models of backtracking. In Proceedings of the 9th ACM SIGPLAN International Conference on Functional Programming. ACM, 54--65. Google Scholar
Digital Library
- Wirth, N. 1985. Programming in Modula-2, 3rd, corrected ed. Springer. Google Scholar
Digital Library
Index Terms
Revisiting coroutines
Recommendations
Compiling with continuations, continued
Proceedings of the ICFP '07 conferenceWe present a series of CPS-based intermediate languages suitable for functional language compilation, arguing that they have practical benefits over direct-style languages based on A-normal form (ANF) or monads. Inlining of functions demonstrates the ...
Coroutines in FORTRAN
A method is described for using coroutines within the strict confines of ANSI FORTRAN. A FORTRAN preprocessor that has been implemented to transform FORTRAN programs, written as if coroutines were allowed, to standard ANSI FORTRAN programs is also ...
Compiling with continuations, continued
ICFP '07: Proceedings of the 12th ACM SIGPLAN international conference on Functional programmingWe present a series of CPS-based intermediate languages suitable for functional language compilation, arguing that they have practical benefits over direct-style languages based on A-normal form (ANF) or monads. Inlining of functions demonstrates the ...






Comments