Re: Generators in PHP

From: Date: Thu, 26 Jul 2012 06:23:28 +0000
Subject: Re: Generators in PHP
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  Groups: php.internals 
Request: Send a blank email to internals+get-61803@lists.php.net to get a copy of this message
I too don't think that a new keyword is necessary for this case. Let's not forget that it is a common practice to document functions with doc blocks, which further helps understanding what it does. /** * @return Generator * @yield string */ function generate() { ... yield $foo; ... } Cheers, Bernhard 2012/7/26 Alex Aulbach <alex.aulbach@gmail.com>: > 2012/7/26 Yahav Gindi Bar <g.b.yahav@gmail.com>: >> "yielder" sounds quite weird don't you think (but my native language is not >> English too.. so don't blame me at english stupid conclusions!) >> >>> Fact: generator is not a good keyword, because too common. >> I can't see the connection... people relate the generator keyword to the iterators so >> what's the problem using it? > > PHP will just complain in existing scripts if you use "generator" as > function-name and stops compiling. I think this is stupid, but that's > a completly different discussion. > >> what about using the "iterator" name as generators keyword? because it does >> return iterators... > > well, wouldn't think, that it can be that easy. > >> iterator foo() { ... yield $bar; ... } sounds OK for me... and got a meaning too. >> though it can confuse some people with the original iterators... > > But it's just what it does. > >> BTW: I still don't think that the generators need a unique word and I suggest using >> functions, but I didn't read al the mails chain, so I assume that I'll find there the >> answer. > > Of course you will! > <making gestures>These are not the droids your looking for. Ups. wrong line. :) > > > -- > Alex Aulbach > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.internals (#61803) next »