Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53772 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 25244 invoked from network); 7 Jul 2011 15:50:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Jul 2011 15:50:34 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@googlemail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@googlemail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.215.42 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@googlemail.com X-Host-Fingerprint: 209.85.215.42 mail-ew0-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:47183] helo=mail-ew0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 69/15-26983-7C5D51E4 for ; Thu, 07 Jul 2011 11:50:33 -0400 Received: by ewy2 with SMTP id 2so360324ewy.29 for ; Thu, 07 Jul 2011 08:50:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=E7XoPQFFbREuodDfeNObwc49/vAzyN8KI0zj2VCEhEQ=; b=neReQTwbJM9AAWGeTp9kyFtqSoci6QS7Ah4rL3Hr+olRD51oAWcLvxbyCe8hlDHd3t ugmTJ2lnbgJX6XmXeEwTo8e22J5NI75LO8T1JxlH4loubfYvBQc6ZKkt1DDw7phds3zm Vcig15Nmpu1+CTp0+WNt+0ZU975bNi2DYMDAc= MIME-Version: 1.0 Received: by 10.14.50.129 with SMTP id z1mr296189eeb.54.1310053827468; Thu, 07 Jul 2011 08:50:27 -0700 (PDT) Received: by 10.14.99.131 with HTTP; Thu, 7 Jul 2011 08:50:27 -0700 (PDT) In-Reply-To: References: <4E145FE2.5000001@php.net> Date: Thu, 7 Jul 2011 17:50:27 +0200 Message-ID: To: Xinchen Hui Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=0023543a27ee05dcaf04a77cada9 Subject: Re: [PHP-DEV] [RFC] foreach_variable supporting T_LIST token From: nikita.ppv@googlemail.com (Nikita Popov) --0023543a27ee05dcaf04a77cada9 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable +1 for adding this. I don't know enough C to review the patches. The first one looks fine thoug= h at first glance (apart from some CS *nits probably, like duplicate parenthesis and usage of if {} else { if {} else {}} instead of if {} elsei= f {} else {}). Your second patch (the one for adding the silence operator) though seems strange. For example you are calling zend_do_begin_silence regardless of whether '@' was used, don't you? On Wed, Jul 6, 2011 at 3:33 PM, Xinchen Hui wrote: > Hi: > > first of all, I am a guy whose english is poor, sorry for making you > confuse. > > the feature request is here: https://bugs.php.net/bug.php?id=3D10203 > > and I think this can make php code more flexible, and more making sense. > > example: > > foreach (array( > array(3, array(1, 2)), > array(7, array(3, 4)), > ) as list($sum, list($op1, $op2))) { > printf("%d + %d =3D %d\n", $op1, $op2, $sum); > } > > output: > 1 + 2 =3D 3 > 3 + 4 =3D 7 > > plz read the RFC for more details. > > thanks > > 2011/7/6 Stefan Neufeind : > > Hi, > > > > On 07/06/2011 03:06 PM, Hannes Magnusson wrote: > >> 2011/7/6 Xinchen Hui : > >>> > >>> T_LIST is not allowed to used with foreach before. > >>> > >>> and then there comes a freature request: #10203 allow > >>> foreach($array as list($a,$b) > >> > >> Ironically enough you managed to miss the last closing ), enforcing > >> the point of this not being a natural syntax. > >> > >> Furthermore, without reading the RFC, is this the same as > >> foreach($array as $a =3D> $b) {} > > > > No, there $a would be the key. Intention would be, as I read the RFC, > > that this could be an arbitrary list. > > > >> or > >> foreach($array as $e) { > >> list($a, $b) =3D $e; > >> } > > > > Yes, I understood if like that. Just a short notation. > > > >> or.. ? > >> > >> that really doesn't look like something PHP should support imo. > > > > Don't see too many bad things about the idea ... > > > > > > Regards, > > Stefan > > > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > -- > =E6=83=A0=E6=96=B0=E5=AE=B8 laruence > Senior PHP Engineer > http://www.laruence.com > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --0023543a27ee05dcaf04a77cada9--