Introducing Coroutines in CS2

Bryant A. Julstrom
Department of Computer Science
St. Cloud State University
St. Cloud, MN 56301
julstrom@eeyore.stcloudstate.edu


Abstract

Coroutines are co-equal program units that transfer control from one to another and preserve their local variables when they are not executing. Though generally considered an advanced topic, they are accessable to students in CS2. This paper describes coroutines and an introduction to them, using the coroutines facility of Modula-2, in CS2.