2012/8/13 Nikita Popov <nikita....@gmail.com>:
>  * 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.

Hm. I think this looks like a workaround over conceptual problems.
The (in my eyes) "right" behavior would be to call a new instance of
the generator if you rewind and destroy the current (= replace current
generator with a new).

I would prefer to say "this is not an real iterator"; if you want to
make it an real iterator, then implement it yourself.

Otherwise it's like "Ok, we have here a new type of function which
looks enough like a function to be a function, which implements an
iterator which looks enough like an iterator to be an iterator.". :)


I also recommend to say, that generators aren't a good idea if used on
resources, which can't be shared. For example: the file-read-example
doesn't lock. To implement locking new functions or a new class is
needed - hiding complexity.

Generators are (in my opinion) really nice for things which are
already in the memory. Not more or less.

-- 
Alex Aulbach

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

Reply via email to