Hi!

> That said, rewind() should behave consistently. I don't feel it makes 
> sense to have rewind() succeed at one point, and fail at another. It 
> would only cause confusion when not familiar with the behavior. Either 
> allow it, or don't. Not both.

It does, since foreach uses rewind. So first rewind should succeed if
you want iterators be usable in foreach. OTOH, on something like DB
result set, next rewind does not make any sense, if you have
non-seekable cursor, since the results consumed are gone and there's no
way to get them back (you could rerun the query, but it might have side
effects and nobody guarantees you'd get the same result anyway). So it
makes sense for the generator to succeed on first rewind but fail on
next ones. Note that generators by nature are stateful objects, so it is
not unexpected that they would produce different result in different
states.

-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to