Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53760 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70158 invoked from network); 6 Jul 2011 13:33:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jul 2011 13:33:48 -0000 Authentication-Results: pb1.pair.com header.from=laruence@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=laruence@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.42 as permitted sender) X-PHP-List-Original-Sender: laruence@gmail.com X-Host-Fingerprint: 209.85.212.42 mail-vw0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:35416] helo=mail-vw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 52/D0-65332-834641E4 for ; Wed, 06 Jul 2011 09:33:46 -0400 Received: by vwl1 with SMTP id 1so5555826vwl.29 for ; Wed, 06 Jul 2011 06:33:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=e1jX+S59gGNVEvxuFakThxCkIOkE2riqw+9zpXqfxeQ=; b=Aukh5jpWLKra5bBdAT4AGYpnEXcD2DIn4b79JjY93lHm0ySF0y36EECNO/s+zicpXf c5/n7067GrPSiPaQ++sGulA92mTSlN4DmeX0j28uSaDoitOiOc1Dt8RH8CJgDDSt9Lcd vcNHawBREPFhwejsC2rMrJOtSI0gU1GDp4pQg= MIME-Version: 1.0 Received: by 10.220.183.10 with SMTP id ce10mr2964358vcb.265.1309959219003; Wed, 06 Jul 2011 06:33:39 -0700 (PDT) Received: by 10.220.95.5 with HTTP; Wed, 6 Jul 2011 06:33:38 -0700 (PDT) In-Reply-To: <4E145FE2.5000001@php.net> References: <4E145FE2.5000001@php.net> Date: Wed, 6 Jul 2011 21:33:38 +0800 Message-ID: To: Stefan Neufeind Cc: internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] foreach_variable supporting T_LIST token From: laruence@gmail.com (Xinchen Hui) Hi: first of all, I am a guy whose english is poor, sorry for making you conf= use. 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 : >>> >>> =C2=A0 T_LIST is not allowed to used with foreach before. >>> >>> =C2=A0 and then there comes a freature request: =C2=A0#10203 =C2=A0allo= w >>> 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, > =C2=A0Stefan > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --=20 =E6=83=A0=E6=96=B0=E5=AE=B8=C2=A0 =C2=A0 =C2=A0 =C2=A0 laruence Senior PHP Engineer http://www.laruence.com