On 08/20/2012 07:56 AM, Ángel González wrote: > On 20/08/12 02:01, Rasmus Lerdorf wrote: >> I would still like to understand what this generator keyword would >> actually do. I don't see how it would work. Would a function marked >> generator somehow not be allowed to return normally or to finish and not >> return anything? How could this be enforced? I am completely against any >> keyword that is essentially documentation-only. >> >> -Rasmus > Given that such function could "return several times", seems a different > enough function type to have its keyword. > You could not decorate it and rely instead on the presence of the yield > keyword, but parsers will thank knowing about it from the start rather > than realising at mid-parsing that the function is a completely > different beast.
So how about something like this: generator function f() { echo "Hello World"; } generator function f() { return 1; } generator function f($arg) { if(f!$arg) yield 1; else if($arg<0) return 1; else return; } What does the generator keyword mean in each of these cases? Anything? Nothing? Would I see a difference either at compile-time or at execute time if I left it out? -Rasmus -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php