> -----Original Message-----
> From: Nikita Popov [mailto:[email protected]]
> Sent: 20 July 2012 21:46
> To: Nikita Popov
> Cc: PHP internals
> Subject: [PHP-DEV] Re: Generators in PHP
>
> On Tue, Jun 5, 2012 at 7:35 PM, Nikita Popov
> <[email protected]> wrote:
> > Hi internals!
> >
> > In the last few days I've created a proof of concept
implementation
> > for generators in PHP. It's not yet complete, but the basic
> > functionality is there:
> > https://github.com/nikic/php-src/tree/addGeneratorsSupport
> >
> > The implementation is outlined in the RFC-stub here:
> > https://wiki.php.net/rfc/generators
>
> A small progress update on this:
>
> * There now is support for yield by reference
Can't yield a reference to an array item directly.
Eg.
function &map(array &$row)
{
yield $row[0];
}
Also seems to be a problem with iterating
foreach(map($row) as &$value)
cannot be done without a fatal error
$i = map($row);
foreach($i as &$value)
however works.
> * Generators are now automatically detected by the presence of
"yield"
> instead of requiring the "*" modifier.
>
> The main open point I still have is whether or not generators
> should have a throw() method (á la Python). I couldn't yet
> find a convincing use case for it, so I'm considering to just
> leave it out.
>
Seems relatively easy to trigger a infinite loop atm.
Typo'd a SQL table name which caused an exception within PDO inside a
generator function, which then caused an infinite loop.
> If there is any further feedback on the proposal, I'd love to
> hear it :)
>
> Nikita
>
> --
> PHP Internals - PHP Runtime Development Mailing List To
> unsubscribe, visit: http://www.php.net/unsub.php
>