Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53158 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34766 invoked from network); 7 Jun 2011 16:07:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Jun 2011 16:07:23 -0000 Authentication-Results: pb1.pair.com smtp.mail=johncrenshaw@priacta.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=johncrenshaw@priacta.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain priacta.com designates 64.95.72.238 as permitted sender) X-PHP-List-Original-Sender: johncrenshaw@priacta.com X-Host-Fingerprint: 64.95.72.238 mx1.myoutlookonline.com Received: from [64.95.72.238] ([64.95.72.238:43337] helo=mx1.myoutlookonline.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5D/B3-15404-ABC4EED4 for ; Tue, 07 Jun 2011 12:07:22 -0400 Received: from st20.mx1.myoutlookonline.com (localhost [127.0.0.1]) by mx1.myoutlookonline.com (Postfix) with ESMTP id 457A88BE089; Tue, 7 Jun 2011 12:07:20 -0400 (EDT) X-Virus-Scanned: by SpamTitan at mail.lan Received: from HUB016.mail.lan (unknown [10.110.2.1]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by mx1.myoutlookonline.com (Postfix) with ESMTPS id A9E848BE12D; Tue, 7 Jun 2011 12:07:09 -0400 (EDT) Received: from MAILR001.mail.lan ([192.168.1.2]) by HUB016.mail.lan ([10.110.17.16]) with mapi; Tue, 7 Jun 2011 12:06:12 -0400 To: Hannes Landeholm , "internals@lists.php.net" Date: Tue, 7 Jun 2011 12:06:57 -0400 Thread-Topic: [PHP-DEV] Inline constructing/cloning and inline foreach listing Thread-Index: AcwlKoKSe+YjA6nlTwys9M+pjlnlmAAAenmA Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: multipart/alternative; boundary="_000_A633CF2D7C7BED41B41F1E64F25507B8060220A1A1MAILR001maill_" MIME-Version: 1.0 Subject: RE: [PHP-DEV] Inline constructing/cloning and inline foreach listing From: johncrenshaw@priacta.com (John Crenshaw) --_000_A633CF2D7C7BED41B41F1E64F25507B8060220A1A1MAILR001maill_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable From: Hannes Landeholm [mailto:landeholm@gmail.com] Sent: Tuesday, June 07, 2011 11:50 AM To: John Crenshaw; internals@lists.php.net Subject: Re: [PHP-DEV] Inline constructing/cloning and inline foreach listi= ng On 7 June 2011 15:53, John Crenshaw > wrote: > foreach ($arrays as list($e1, $e2, $e3)) { ... Disagree. This feels very obtuse. I wouldn't expect this construct to work = at all, and even if it did, it is highly ambiguous (I.E. at first I thought= you were intending to grab 3 entries at a time, rather than extracting ent= ries from a second array). John Crenshaw Priacta, Inc. I don't understand what's ambiguous? For each iteration the foreach assigns= the current value to the variable $value specified as either "as $key =3D>= $value" or "as $value". The "as" keyword is simply a type of assignment op= erator that assigns the current element to the right expression. Since PHP = has a special "list()" language construct for assignment it doesn't make se= nse that "list(...) =3D $something" assignment would work but not "array($s= omething) as list(...)". Grabbing "3 elements at a time" is not logical at all. Why would the list c= onstruct change how the foreach iterates? Hannes The proposed meaning IS the more logical of the two, but that didn't stop m= e from being confused when I first looked at the construction. Like I said,= at first glance I thought you were trying to iterate 3 at a time and I tho= ught "why would we want the language to support THAT?" In any case, I'm just one person, and I don't entirely care for list() in t= he first place so I'm probably biased, but this construct seems wrong to me= . John Crenshaw Priacta, Inc. --_000_A633CF2D7C7BED41B41F1E64F25507B8060220A1A1MAILR001maill_--