Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62596 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16952 invoked from network); 30 Aug 2012 08:39:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Aug 2012 08:39:18 -0000 Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; 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:53358] helo=xdebug.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 40/52-02911-5B62F305 for ; Thu, 30 Aug 2012 04:39:17 -0400 Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id 8E1EADE13E; Thu, 30 Aug 2012 09:39:14 +0100 (BST) Date: Thu, 30 Aug 2012 09:39:14 +0100 (BST) X-X-Sender: derick@whisky.home.derickrethans.nl To: Gustavo Lopes cc: Nikita Popov , 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, Gustavo Lopes wrote: > On Wed, 29 Aug 2012 22:10:52 +0200, 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?! > > 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