Re: [RFC] foreach_variable supporting T_LIST token

From: Date: Tue, 23 Aug 2011 03:43:56 +0000
Subject: Re: [RFC] foreach_variable supporting T_LIST token
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-54812@lists.php.net to get a copy of this message
Hi: I found this feature was decided to do in PHP 5.3 TODO list : http://svn.php.net/viewvc/php/php-src/branches/PHP_5_3/TODO?revision=242949&view=markup so I was wondering does this previous decision still shoudl be think as valid? hehe thanks 2011/7/7 Xinchen Hui <laruence@gmail.com>: > Hi: > >   thanks very much for this, that second patch is a wrong one,  updated .. > > thanks > > 2011/7/7 Nikita Popov <nikita.ppv@googlemail.com>: >> +1 for adding this. >> >> I don't know enough C to review the patches. The first one looks fine though >> at first glance (apart from some CS *nits probably, like duplicate >> parenthesis and usage of if {} else { if {} else {}} instead of if {} elseif >> {} 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 <laruence@gmail.com> 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=10203 >>> >>>  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  = %d\n", $op1, $op2, $sum); >>>  } >>> >>>  output: >>>  1 + 2  = 3 >>>  3 + 4  = 7 >>> >>>  plz read the RFC for more details. >>> >>> thanks >>> >>> 2011/7/6 Stefan Neufeind <neufeind@php.net>: >>> > Hi, >>> > >>> > On 07/06/2011 03:06 PM, Hannes Magnusson wrote: >>> >> 2011/7/6 Xinchen Hui <laruence@gmail.com>: >>> >>> >>> >>>   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 => $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) = $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 >>> > >>> > >>> >>> >>> >>> -- >>> 惠新宸        laruence >>> Senior PHP Engineer >>> http://www.laruence.com >>> >>> -- >>> PHP Internals - PHP Runtime Development Mailing List >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> >> >> > > > > -- > 惠新宸        laruence > Senior PHP Engineer > http://www.laruence.com > -- 惠新宸        laruence Senior PHP Engineer http://www.laruence.com

« previous php.internals (#54812) next »