On Sun, Aug 12, 2012 at 10:08 PM, Brian Moon <br...@moonspot.net> wrote:
> 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.

Currently I'm planning to implement the following behavior for rewind():

 * If before first yield: Resume to first yield (this priming behavior
is common to all the Iterator methods)
 * At first yield: No-op
 * After first yield: Recoverable fatal error

So this would allow you to call ->rewind() after creating the
generator, but will throw an error if you try to do so later.

Another thing that I'd like to do is drop the ->close() method. It
doesn't really make sense to explicitly close generators.

Any objects to those two things?

Nikita

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

Reply via email to