Just please don't forget that "generator" isn't quite a rare word (unlike "yield"), so there are high chances for collisions (in particular with namespaced code). So if you have some kind of Code\Generator class, you're screwed.
Keywords don't grow on trees, you know ;) Also I'd like to point out that being similar to other languages is in the general case a *good* thing. So if you say "It doesn't matter how it is implemented in other languages, because we talk about PHP and not other languages.", then I say you're wrong. Deviating from the "standard" generator implementation without having good reasons seems rather pointless to me. Furthermore the fact that many languages can live without some special generator keyword already speaks for itself. I am not aware of any problems it caused there. Also: This is the kind of real "experience" that matters here. Those languages have implemented generators for years and showed that they work well. Nikita PS: This is not really a reply to you, Dave, just to the recent discussion in general. On Wed, Jul 25, 2012 at 7:58 PM, Dave Ingram <d...@dmi.me.uk> wrote: > >> Fact: Adding a new name for a special kind of function as a syntax >> construct is going to cost (possibly unnecessary) time and energy, >> because now you have functions, and weird things that look almost like >> functions but aren't and can only be used to make generators. > > Just to put my oar in too, as an interested watcher... > > I don't think that it's a problem (from that point of view) to have a > generator keyword. Explicitly declaring up front that it's a generator means > that the "return" keyword in the body is always a mistake. Likewise with > "function" and "yield". I don't think it would be confusing to have > something that looks like a function but isn't completely the same. In fact, > it's almost (but not quite) like declaring a return type for the function. > > > > D > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php