Hi!

> There is a relatively simple (at least conceptually) way to make generators
> rewindable: Remember the original arguments of the function, and basically
> "re-invoke" it on rewind().

That is provided that:
1. The original arguments of the function can be "remembered" - those
can be complex object with a lot of state, not always visible to PHP,
preserving which may be impossible.
2. The generator function is pure and does not have side effects - or at
least side effects of rewinding are expected and desirable.

It also means that we'd have to always preserve the arguments of the
generator function in the state they were when it was called or at least
try to - not sure what performance impact this implies. That or
explicitly declare the generator rewindable with the implication that
once we declare that we shouldn't pass any arguments to it that can't be
or shouldn't be preserved.

-- 
Stas Malyshev
smalys...@gmail.com

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

Reply via email to