Boost logo

Boost :

Subject: Re: [boost] {Review] Coroutine reviewstarts today, September 3rd
From: Conrad Poelman (cpnabble_at_[hidden])
Date: 2012-09-14 19:34:14


Sorry I missed the official review period, I just wanted to pipe up to say
that I've been severely missing the lack of a "generator" functionality in
C++ for almost two decades, having become very accustomed to it in CLU (the
language that inspired the "yield" concept for both C# and Python) where
they were called "iterators." So I'm very excited to see it become part of
the boost library and expect to heavily use it. I think generators can
revolutionize the way C++ programmers iterate over collections, complex
structures like trees, and potentially infinite sequences by making such
abstractions very easy to write and easy to use.

I built and played with this library a bit using Microsoft Visual Studio
2010. My thoughts so far:

- I like the idea of incorporating Eugene Yakubovich's adapter to allow use
of generators in range-based for loops (though I didn't try it since VS 2010
doesn't support those yet.) Being able to call generators with a syntax like
"for( int x: evens(10))" or "BOOST_FOREACH( int x, evens(10) )" will make
them ridiculously easy to use. I also like the suggestion of not requiring a
return statement or yield_break() to end the generator.

- Changing the interface to return boost::optional as was suggested has a
potential minor drawback in terms of performance, but it creates a very
clean and simple single-call interface, provided it's made clear that first
time the optional returns nothing, iteration is complete. Also I'd hope that
this does not conflict with supporting the above range-base-for syntax.

- In the first example in the coroutine documentation ctx.is_complete() is
called but ctx is not defined - I believe that should be c.is_complete()?

Thank you and I enthusiastically look forward to using boost generators.

--
View this message in context: http://boost.2283326.n4.nabble.com/Review-Coroutine-reviewstarts-today-September-3rd-tp4635140p4635775.html
Sent from the Boost - Dev mailing list archive at Nabble.com.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk