Ary Borenszweig wrote: > D should provide a yield keyword that basically > rewrites the body of the method into the first code.
Don't need to change the language for that.
=========
string yield(string what) {
return `if(auto result = dg(`~what~`)) return result;`;
}
class Foo
{
uint array[2];
int opApply(int delegate(ref uint) dg) {
mixin(yield("array[0]"));
mixin(yield("array[1]"));
return 0;
}
}
=========
Compiles and runs as expected, on today's D.
