
Am 19.09.2012 20:12, schrieb Vicente J. Botet Escriba:
I forgot a suggestion made by Vicente:
5.a coroutine<>::caller_t provides function bind() which must be called after coroutine::caller_t::yield() returned in order to get the parameters
int f( caller_t & c, strg & s, int x) { c.yield( 7); // alternative c( 7) c.bind( s, x); // s and x will contain new values given by caller } My suggestion was to call bind just once at the beginning of function and before any call to yield. If you want to ensure that the bind has been done, you could request
Le 19/09/12 14:23, Oliver Kowalke a écrit : that yield is provided by the result of the bind operation, as e.g.
int f( caller_t & c, strg & s, int x) { auto b = c.bind( s, x); // s and x are now used to store the next calls. b.yield( 7); // alternative b( 7) // here s and x have been reassigned } OK - what if a user forgets to bind ? Maybe we can force the user to bind:
int f( caller_t & c, strg & s, int x) { caller_t::yield_t b = c.bind( s, x); // s and x are now used to store the next calls. b.yield( 7); // alternative b( 7) // here s and x have been reassigned } c.bind() retrieves the addresses of the parameters used to store the values (for each entering of f). only yield_t will provide yield() function. what do you think? Oliver