Re: [VOTE] Generators
| From: | Gustavo Lopes | Date: | Wed, 29 Aug 2012 20:49:57 +0000 |
| Subject: | Re: [VOTE] Generators | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-62586@lists.php.net to get a copy of this message | ||
On Wed, 29 Aug 2012 22:10:52 +0200, Derick Rethans <derick@php.net> wrote:
On Wed, 29 Aug 2012, Nikita Popov wrote: function &bind(array $keys, array &$row) {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. -- Gustavo Lopesforeach($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.