Hi Nikita,
I admit, I have ignored these threads as there was no RFC. So, some of
this may have been covered.
Do you have a good example usage other than a file? I don't find
fopen/fgets/fclose all that complicated. What are the other valid use
cases for such a thing?
Also, not allowing rewinding is unintuitive for something that is an
iterator in PHP. If I can foreach() it and I can call next() on it, I
expect to be able to reset() it as well. IMO, you would need to issue a
FATAL PHP error if that simply is not allowed. Or you have to have a
second syntax for what to do in that case. At that point, you are
implementing Iterator.
While I am glad that PHP has borrowed syntax from many languages, I find
the yield keyword to be very WTF when I first saw it. It is also poorly
explained in your RFC. You use terms like "sending and receiving". That
does not say "returns from function execution" to me. I had to basically
figure it out from the code examples.
Lastly, because you cite needing this for sending data to PHPUnit, I
think this is a user land problem and not a core problem. In about 5
minutes I implemented a reusable Generator object that does exactly what
you need. http://pastebin.com/V336rEpR At least, it does what your
examples show you need. Again, file IO is very easy and perhaps that
example does not explain your true need very well.
Brian
brianlm...@php.net
http://brian.moonspot.net/
On 8/11/12 8:42 AM, Nikita Popov wrote:
Hi internals!
I think there already was a lot of discussion on the generators, so
it's time to move to the next step. I'd like to vote on the feature in
two weeks, so this the "announce[ment] on internals@, by the author,
with the intention of voting on it".
https://wiki.php.net/rfc/generators
If you have any further feedback, now would be a good time to raise
it. If there is something you previously posted, but which I didn't
yet address, please let me know. There were around 150 mails and I
sure missed some of them.
Thanks,
Nikita
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php