RE: [PHP-DEV] [RFC] Loop... or...

2014-09-22 Thread Christian Stoller
From: Leigh [mailto:lei...@gmail.com] Sent: Friday, September 19, 2014 11:57 PM Traditionally this is requested as a loop {} else {} structure, however due to the choice of keyword this causes significant BC problems. I have written an RFC presenting this feature as loop {} or {} along

Re: [PHP-DEV] [RFC] Loop... or...

2014-09-22 Thread Xinchen Hui
Hey: On Sat, Sep 20, 2014 at 5:56 AM, Leigh lei...@gmail.com wrote: Hello list! This is an item that has been repeatedly requested in various forms, with no solid implementation to back it up, yet remaining quite desirable to the developer community at large. Loops with a default block,

Re: [PHP-DEV] [RFC] Loop... or...

2014-09-22 Thread Leigh
On 22 September 2014 08:17, Christian Stoller stol...@leonex.de wrote: I like this proposal as I am using this feature in Twig very often. But I would really prefer using else instead of or, because it is already common in the mentioned projects. Maybe you could reconsider if it is really not

Re: [PHP-DEV] [RFC] Loop... or...

2014-09-22 Thread Leigh
On 22 September 2014 08:49, Xinchen Hui larue...@php.net wrote: Maybe I am too conservative. I don't like this idea. : And I DO THINK, we should try to stop brings lots of new things into PHP7. I am worring whether it can be release in the next year Can you give some more

Re: [PHP-DEV] [RFC] Loop... or...

2014-09-22 Thread Michael Wallner
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

Re: [PHP-DEV] [RFC] Loop... or...

2014-09-21 Thread Patrick Schaaf
Am 21.09.2014 02:22 schrieb Sara Golemon poll...@php.net: 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

Re: [PHP-DEV] [RFC] Loop... or...

2014-09-20 Thread Leigh
On 20 September 2014 01:02, Rowan Collins rowan.coll...@gmail.com wrote: It seems like there are actually quite a number of special blocks you *could* define, such as: a) When the body is executed zero times (proposed or block) b) When the body is executed exactly once (in a do...while loop,

Re: [PHP-DEV] [RFC] Loop... or...

2014-09-20 Thread Rowan Collins
On 20 September 2014 15:43:46 GMT+01:00, Leigh lei...@gmail.com wrote: On 20 September 2014 01:02, Rowan Collins rowan.coll...@gmail.com wrote: It seems like there are actually quite a number of special blocks you *could* define Some or all of these can be implemented (in other RFCs). However

Re: [PHP-DEV] [RFC] Loop... or...

2014-09-20 Thread Sara Golemon
On Sep 19, 2014, at 14:56, Leigh lei...@gmail.com wrote: https://wiki.php.net/rfc/loop_or 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

Re: [PHP-DEV] [RFC] Loop... or...

2014-09-20 Thread Leigh
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

Re: [PHP-DEV] [RFC] Loop... or...

2014-09-20 Thread Leigh
On 20 September 2014 23:06, Leigh lei...@gmail.com wrote: 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. NikiC and Bob have convinced me to carry on with the original proposal, and bring up

Re: [PHP-DEV] [RFC] Loop... or...

2014-09-20 Thread Sara Golemon
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?

Re: [PHP-DEV] [RFC] Loop... or...

2014-09-20 Thread Sara Golemon
On Sat, Sep 20, 2014 at 5:16 PM, Leigh lei...@gmail.com wrote: On 20 September 2014 23:06, Leigh lei...@gmail.com wrote: 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. NikiC and Bob have

[PHP-DEV] [RFC] Loop... or...

2014-09-19 Thread Leigh
Hello list! This is an item that has been repeatedly requested in various forms, with no solid implementation to back it up, yet remaining quite desirable to the developer community at large. Loops with a default block, executed in the event that the loop is never entered.

Re: [PHP-DEV] [RFC] Loop... or...

2014-09-19 Thread Rowan Collins
On 19/09/2014 22:56, Leigh wrote: Hello list! This is an item that has been repeatedly requested in various forms, with no solid implementation to back it up, yet remaining quite desirable to the developer community at large. Loops with a default block, executed in the event that the loop is

Re: [PHP-DEV] [RFC] Loop... or...

2014-09-19 Thread Leigh
On 19 September 2014 23:08, Rowan Collins rowan.coll...@gmail.com wrote: It's worth noting that both Smarty and Twig implement a similar mechanism in their respective foreach loop syntax. Smarty spells it {foreachelse} http://www.smarty.net/docs/en/language.function.foreach.tpl Twig spells

Re: [PHP-DEV] [RFC] Loop... or...

2014-09-19 Thread Andrea Faulds
On 19 Sep 2014, at 22:56, Leigh lei...@gmail.com wrote: Loops with a default block, executed in the event that the loop is never entered. https://wiki.php.net/rfc/loop_or While this might be useful, I’d prefer we copy Python’s else behaviour, where a block of code is executed when break

Re: [PHP-DEV] [RFC] Loop... or...

2014-09-19 Thread Leigh
On 19 September 2014 23:47, Andrea Faulds a...@ajf.me wrote: While this might be useful, I’d prefer we copy Python’s else behaviour, where a block of code is executed when break is never used. This feature makes code that does, for example, a linear search nicer to read. -- Andrea Faulds

Re: [PHP-DEV] [RFC] Loop... or...

2014-09-19 Thread Andrea Faulds
On 20 Sep 2014, at 00:10, Leigh lei...@gmail.com wrote: I understand the desire for something python-like, however it certainly doesn't fall under the or keyword. Why not? Python uses “else”, and before creating this RFC you initially wanted to use “else”. If anything we could probably

Re: [PHP-DEV] [RFC] Loop... or...

2014-09-19 Thread Leigh
On 20 September 2014 00:15, Andrea Faulds a...@ajf.me wrote: Why not? Python uses “else”, and before creating this RFC you initially wanted to use “else”. Then I realised it was folly. Documented in the RFC why else is a bad choice. I’m bringing it up because I think we’re only going to end

Re: [PHP-DEV] [RFC] Loop... or...

2014-09-19 Thread Rowan Collins
On 19/09/2014 23:47, Andrea Faulds wrote: On 19 Sep 2014, at 22:56, Leigh lei...@gmail.com wrote: Loops with a default block, executed in the event that the loop is never entered. https://wiki.php.net/rfc/loop_or While this might be useful, I’d prefer we copy Python’s else behaviour, where a

Re: [PHP-DEV] [RFC] Loop... or...

2014-09-19 Thread Rowan Collins
On 20/09/2014 01:02, Rowan Collins wrote: I certainly don't see (a) and (f) as being at all mutually exclusive. Sorry, that was meant to say (a) and (e). Or, in plain English, I don't see why we couldn't have both Smarty-style if the loop executed zero times and Python-style if the break