Generator use-cases

Kris Zyp kris at sitepen.com
Fri Mar 28 21:09:11 PDT 2008


> Generators, besides supporting one level of coroutine suspending and 
> (re-)calling, are the cheapest way to implement an iterator.

I think Neil's inspiring demonstration of pseudo-threading with generators 
is also worthy of inclusion in your list of generator use cases:
http://www.neilmix.com/2007/02/07/threading-in-javascript-17/
It is quite interesting in that single level coroutines can be combined to 
create multi level coroutines in a form that provides explicit control of 
creating composable flow or maintaining atomicity. Generators are a pretty 
powerful and valuable construct, IMO. I certainly hope they stay in ES4 as 
well.
Kris 




More information about the Es4-discuss mailing list