Proposal idea - generators (original) (raw)

Adrian Kuhn akuhn at iam.unibe.ch
Sun Mar 29 16:29:28 PDT 2009


Tim Peierls wrote

My sense (bolstered by a quick Google code search) is that people have been coming up with this kind of functionality on their own as they encounter a need for it. Is it really something that needs special language support? Using another thread to do the generation is quite reasonable. You can build a nice coroutine-style facility with a pair of SynchronousQueues (or, more generally and flexibly, with TransferQueues, expected for Java 7; or maybe with Phasers). Using that as a building block you could then rewrite your example below as something like this:

Language support for generators is a must have! Threads are a
workaround only. With proper language support generators can be
realized as state machine. See the following article (Jon Skeet to the
rescue :)

http://csharpindepth.com/Articles/Chapter6/IteratorBlockImplementation.aspx

cheers, AA

-- Adrian Kuhn Software Composition Group University of Bern, Switzerland http://www.iam.unibe.ch/~akuhn



More information about the coin-dev mailing list