On 2014-09-21 02:21, Sara Golemon wrote: > On Sat, Sep 20, 2014 at 3:03 PM, Leigh <lei...@gmail.com> wrote: >> On 20 September 2014 20:47, Sara Golemon <p...@golemon.com> wrote: >>> I like the general idea, but rather than explicitly focusing on >>> the 'or' keyword, how about just giving all loop constructs >>> (do/while/for/foreach) a return value? I'd suggest an integer >>> return value indicating the number of times the loop executed. >>> >> >> mind === blown >> >> This would open up a huge amount of other functionality I'd never >> dreamed of (some of which is quite scary!) >> >> for($i = for(...) {}; $i < ...) {} >> > Yikes, I truly hope nobody ever writes that code. Ever. > >> I'm really not sure I understand the full implication of this >> though. This would mean changing loop constructs from statements >> to expressions. I wonder how difficult that will actually be, and >> what other problems it would cause (I obviously haven't played with >> this idea yet). >> > I admit, I haven't thought it through entirely either. Nor even if > it's definitely possible. > >> It would also mean having to make { default block } into an >> expression... with a return value (to be allowed on either side of >> the boolean or) >> > Excellent point, a block only works with T_OR if it has a value. > I'm pretty sure that at this point, it doesn't. That does put a > monkey wrench into it. Perhaps a lambda could accommodate that? > Starts to get ugly though... > >> Lots to think about here, if it's at all viable this will need >> it's own separate RFC, it's a much more invasive change, but >> definitely a great idea. >> > Yeah, I might be trying too hard. Worth exploring a tiny bit > though... > > -Sara >
Actually, I once or twice wanted to use while() {} else {} instead of wrapping the loop in an "if". The extended version of Sara, while looking great at a first glance, quickly turns into a crazy nightmare after looking at the points already cooked up :) -- Regards, Mike -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php