Boost logo

Boost :

From: Darryl Green (darryl.green_at_[hidden])
Date: 2005-06-03 00:58:53


Maksym Motornyy <mmotorny <at> yandex.ru> writes:
>
> The same code in C++ (using my library) will look like:
>
> class simple_generator
> {
> public:
> YIELD_BEGIN_WITH_CTOR( simple_generator, int )
> YIELD_FOR_0( i = 1, i < 4, ++i )
> YIELD_FOR_1( j = 1, j < 4, ++j )
> YIELD_RETURN( i * j )
> YIELD_END_FOR_1
> YIELD_END_FOR_0
> YIELD_END
>
> private:
> int i;
>
> int j;
> };

Nice idea - but a tad ugly.

Have you seen http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html
which deascribes a similar approach in C?

I don't actually find this terribly compelling - and it looks like the C#
implementation is just as limited, but at least has nicer syntax than a
macro hack can manage. I would be far more interested in real coroutines.

Regards
Darryl.


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