Hi! > The implementation is outlined in the RFC-stub here: > https://wiki.php.net/rfc/generators > > Before going any further I'd like to get some comments about what you > think of adding generator support to PHP.
Some notes on the RFC: 1. I think we should support rewind() by just creating a new generator instance (i.e. doing the same that is done when generator is called for the first time). If it depends on the resource that generator changes as a side effect, so be it. rewindable() looks like unnecessary complication which IMHO will not be useful in most cases. 2. I understand the pre-yield code is called on current(). What about key()? I think it makes sense to call it there too - i.e. pre-yield code is called whenever first key() or current() - it should be made explicit. 3. return values. I think non-empty return in generator should produce a notice or E_STRICT. 4. What happens to the state variables when generator is cloned? Just addref or real cloning for objects? 5. Are multiple yields allowed? I.e. the rfc mentions something like yield yield $a - what that would mean? I'd allow yield only be applied to variable expression (lval) because double yield doesn't make sense to me, but maybe I miss something. 6. “Sending values” section seems to be missing. Especially useful would be to cover what happens with keys there and what is the syntax there - is it just "$a = yield;"? Or does it mean when yield is used in expression it becomes incoming yield? And, last but not least - do we need sending into generators at all? 6. What happens if you send into a by-ref generator? Is the data sent by-ref then? What if it's an expression that can't be send by-ref? -- 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