Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62587 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 76111 invoked from network); 29 Aug 2012 21:19:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Aug 2012 21:19:48 -0000 Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.113.146.227 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.113.146.227 xdebug.org Linux 2.6 Received: from [82.113.146.227] ([82.113.146.227:32774] helo=xdebug.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B1/F2-59480-3778E305 for ; Wed, 29 Aug 2012 17:19:48 -0400 Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id AC1B5DE13D; Wed, 29 Aug 2012 22:19:44 +0100 (BST) Date: Wed, 29 Aug 2012 22:19:44 +0100 (BST) X-X-Sender: derick@whisky.home.derickrethans.nl To: Nikita Popov cc: Jared Williams , PHP internals In-Reply-To: Message-ID: References: <20120829162147.QQCM24459.aamtaout04-winn.ispmail.ntl.com@p2> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: [PHP-DEV] [VOTE] Generators From: derick@php.net (Derick Rethans) On Wed, 29 Aug 2012, Nikita Popov wrote: > On Wed, Aug 29, 2012 at 10:10 PM, Derick Rethans 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?! > > To my knowledge all iterator-related functionality is supposed to > throw exceptions (as it is a feature related to the object oriented > part of PHP). At leas this is what a quick search of the code base > gave me. (See http://lxr.php.net/xref/PHP_TRUNK/ext/spl/spl_dllist.c#1248 > for example). "ext/spl" - SPL is not *core* language. The generators are. Don't throw exceptions from core features! Derick