On Wed, 29 Aug 2012, Gustavo Lopes wrote:

> On Wed, 29 Aug 2012 22:10:52 +0200, Derick Rethans <der...@php.net> wrote:
> 
> > On Wed, 29 Aug 2012, Nikita Popov wrote:
> > 
> > > > function &bind(array $keys, array &$row)
> > > > {
> > > >         foreach($keys as $key)
> > > >                 yield $key => $row[$key];
> > > > }
> > > > 
> > > > $row = [];
> > > > $it = bind(['a', 'b'], $row);
> > > > 
> > > > foreach($it as $key => &$ref)
> > > >         echo $key;
> > > > echo "\n";
> > > > foreach($it as $key => &$ref)
> > > >         echo $key;
> > > 
> > > Thanks, this is now fixed. It'll throw an exception now, saying that
> > > you can't traverse an already closed generator.
> > 
> > Nothing in the core throws an exception, why would this?!
> 
> This is not accurate. All the iterators throw exceptions on similar 
> situations. Generators are iterators, so I see no deviation from the 
> norm here.

Nothing shows that they are. In any example I saw, I don't even see any 
OO syntax/functionality. For me, "yield" is a core syntax *keyword*, and 
hence: no exceptions.

cheers,
Derick

-- 
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug
Posted with an email client that doesn't mangle email: alpine

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

Reply via email to