Derick Rethans wrote:
I think the first thing anyone who uses generators must understand is that
>they are iterators.
You forget that not even everybody that uses PHP knows what an iterator
is. For all they care, they have an array they can run foreach() on.
>They should be compared with iterators, not arrays.
They shouldn't be compared with either. They are magical things that
happen with a "yield" keyword.
Seconded ...
But hiding things behind 'magic' is the problem here :(
Personally for 'generators' to be any use to me I need to be able to ask them
what is wrong rather than be blown out somewhere else because something
unexpected happened. If it was a data stream then I'd just check $gen->error();
or $gen->noofrows to see what had happened ... nothing magic at all. But using
magic necessitates exceptions since there is no other way of handling the
errors? Is there no way we can 'check the state' of a generator in-line ...
$gen->status for example? Surely this is just a matter of passing an 'at end of
file' flag for example where you ARE reading an empty generator? Rather than
just bailing out to an exception?
--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php