[racket-dev] Coroutines (mzlib/thread)

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Fri Jul 20 21:48:38 EDT 2012

There are two notions of coroutines and they actually are distinct forms of control abstractions. There are the ones that explicitly yield and received their name from Simula 67. And then there are the ones that implicitly yield (time, certain events) and then some 'master' picks the next one to run (depending on some conditions); in Simula 67 this is a 'pattern'. We can build it for real. Both interfaces have separate uses and should be kept separate. -- Matthias

On Jul 20, 2012, at 4:50 PM, Asumu Takikawa wrote:

> Hi all,
> I've been moving some libraries from mzlib to more appropriate places
> recently. I was meaning to move `mzlib/thread` to `racket/coroutine`,
> but had some questions about its API.
> It appears that the coroutines from `mzlib/thread` don't actually
> provide a built-in way to yield the computation to another coroutine.
> Instead, the coroutine is run with either a timeout or an event that
> suspends the computation and returns to the caller.
> Is this a useful coroutine API? It seems that to encode the typical
> `yield` construct you need to set up your own protocol with, say, a
> channel to trigger a context switch and then do scheduling manually. If
> we're going to bother providing it as a `racket` library, should we try
> to improve the API?
> NB: the only use I could find in the code base was in
> framework/private/color.rkt.
> Cheers,
> Asumu
> _________________________
>  Racket Developers list:
>  http://lists.racket-lang.org/dev

Posted on the dev mailing list.