Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62585 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71783 invoked from network); 29 Aug 2012 20:48:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Aug 2012 20:48:16 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.42 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.215.42 mail-lpp01m010-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:60756] helo=mail-lpp01m010-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 52/12-59480-F008E305 for ; Wed, 29 Aug 2012 16:48:15 -0400 Received: by lahl5 with SMTP id l5so1106636lah.29 for ; Wed, 29 Aug 2012 13:48:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=AJcZZmIgD5dHNVOsnLcN7OASMQ3g2zd7LuuwezmHZps=; b=IDoiv+eNt/s10bWSiBlSHDzNUGb9wl+BVQyVxzQiFZJ917YIk+H4QtugTtCLaLniQ1 lRS9uBFpY2BfVhqon6mbvVa5KyOVGr6QLUnGhSfTKLmn+pJjF/Sbl4UmoZ71mOo2RBf9 TTnJeGw/RrON/NbCs7cxDCepxVBhNP25b3CaGHIwAiVDeFYW1+pqkfrZcrRcioykZK+n Ek0pnNSPdHXzDg8aXyTGT3He7kLDZ9m1G2EqlTRI/6ZI+cj1Tzx8UY1I83AqnI3+Qrnx nFyoo1CgigxJwXnKNdb1EO/HRaeGibkmAAkPrAy7jW9vZd5YSGj7nIjJpJFvxhzupViH SSIA== MIME-Version: 1.0 Received: by 10.152.131.68 with SMTP id ok4mr1351379lab.47.1346273292309; Wed, 29 Aug 2012 13:48:12 -0700 (PDT) Received: by 10.152.108.145 with HTTP; Wed, 29 Aug 2012 13:48:12 -0700 (PDT) In-Reply-To: References: <20120829162147.QQCM24459.aamtaout04-winn.ispmail.ntl.com@p2> Date: Wed, 29 Aug 2012 22:48:12 +0200 Message-ID: To: Derick Rethans Cc: Jared Williams , PHP internals Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] [VOTE] Generators From: nikita.ppv@gmail.com (Nikita Popov) 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). Nikita