
On 01/03/2012 01:05 PM, Huang Huan wrote:
1. return e.g. boost::function<char(int)> f = ( if_ ( _1>= 0 ) [ return_('a') ], return_('b') ); p.s. return should be supported.
return is hard to implement, since each expression is building its own expression, so you need to forward it along the whole chain. Exceptions could also be used, but it's not very nice.
2. iterator/iteration generation by lambda using yield return/yield break const char* p; // we shuld use the local var inside lambda instead of this var p. refer to section 3 iteration<char> it = ( for_(var(p) = _1, *var(p), var(p)++) [ if_(*var(p) != ' ') [ yield_return(*var(p)) ] if_(*var(p) == ';') [ yield_break() ] ] ) ("I love this game; no use"); p.s. The packing iteration interface is very like the yield keyword in C# IEnumeable
yielding requires something like coroutines, with Boost.Context for example.
3.local/global var declare and using e.g. char a; var_name x, y, z; global_var<int>(y); // put this line inside lambda is ok, just before use it ( ( local_var<int>(x), // local var declare // global_var<int>(y), var(a) = 'a', var<int>(x) = _2, // using local var x ), ( local_var<char>(z), var(a), var<int>(x) = _1, // error! x is not local var here. var<int>(y), // ok for global even if another lambda var<char>(z) = 'b', ) ) p.s. Now, in my work. It's hard to simplify var<T>(x) to var(x). It's a hard template working.
Boost.Phoenix provides local variables using let/in syntax.