Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Stas Malyshev
Hi! > And this, which is completely undetectable at parse time: > > $bar = 30; > // ... arbitrary amount of code > switch ( $foo ) { > case $bar: > case 30: > } That's not all. You can also do: switch (true) { case foo($bar): ... case baz($quz, $qux): ... } and this is a complet

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Kris Craig
On Wed, Aug 13, 2014 at 3:21 PM, Drew Paroski wrote: > On 6 August 2014 12:32, Ferenc Kovacs wrote: > > > > I'm not sure what would be the best solution, but if we don't version the > > spec, then when we introduce BC breaks or simply new features in a new > > version which is in turn get's adde

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Drew Paroski
On 6 August 2014 12:32, Ferenc Kovacs wrote: > > I'm not sure what would be the best solution, but if we don't version the > spec, then when we introduce BC breaks or simply new features in a new > version which is in turn get's added to the spec, that would make the older > php version's(from any

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Matthew Fonda
On Wed, Aug 13, 2014 at 3:24 AM, Peter Cowburn wrote: > > My thoughts on the topic? I think we're in danger of letting "process" get > in our way here. It's a bug fix which IMHO should even be thrown into 5.6 > (this is a bug fix!). Going through the RFC process, being forced to wait > for 5.7 or

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Pierre Joye
On Wed, Aug 13, 2014 at 5:42 PM, Sara Golemon wrote: > I woke up to this thread, and at first I thought: > > Oh, some actual discussion, maybe we should stop the vote after all > and give it some time... > One or two minor points here... > And there's the bike shed. > > For my own sanity, I'm goin

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Sara Golemon
I woke up to this thread, and at first I thought: Oh, some actual discussion, maybe we should stop the vote after all and give it some time... One or two minor points here... And there's the bike shed. For my own sanity, I'm going to leave this to the people who care about the import things like

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Ferenc Kovacs
On Wed, Aug 13, 2014 at 5:20 PM, Kalle Sommer Nielsen wrote: > Hi > > 2014-08-13 13:02 GMT+02:00 Ferenc Kovacs : > > agree, and I thought about mentioning that, but I left that out, because > > I'm not proposing to remove that ability (and I see more use-cases for > that > > as mentioned in my p

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Kalle Sommer Nielsen
Hi 2014-08-13 13:02 GMT+02:00 Ferenc Kovacs : > agree, and I thought about mentioning that, but I left that out, because > I'm not proposing to remove that ability (and I see more use-cases for that > as mentioned in my previous email) but stating that this patch would make > an arbitrary distinc

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread James
Even if it is fall through that is causing the behavior it still is a syntax that no longer will be considered valid in a minor release - and seemingly in a point release as well if everyone had their way here. [: Not that I consider code likehttp://3v4l.org/ mtG4K

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Ferenc Kovacs
On Wed, Aug 13, 2014 at 3:55 PM, Rowan Collins wrote: > Ferenc Kovacs wrote (on 13/08/2014): > >> I think you misunderstood that part, I was thinking about a state machine >> like this: >> >> 1. function doStuff(){ >> 2. switch($state){ >> 3. case OPENDOOR: >> 4. if(!opendoor()){ >> 5. break

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Rowan Collins
Ferenc Kovacs wrote (on 13/08/2014): I think you misunderstood that part, I was thinking about a state machine like this: 1. function doStuff(){ 2. switch($state){ 3. case OPENDOOR: 4. if(!opendoor()){ 5. break; 6. } 7. $state = SITDOWN; 8. case SITDOWN: 9. if(!sitdown()){ 10

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Ferenc Kovacs
On Wed, Aug 13, 2014 at 3:42 PM, Rowan Collins wrote: > Ferenc Kovacs wrote (on 13/08/2014): > >> >> It is not selecting the first default, it just never needs to look >> for a default, because it has already found a matching case label. >> >> >> yes, and it continues the execution from t

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Rowan Collins
Ferenc Kovacs wrote (on 13/08/2014): It is not selecting the first default, it just never needs to look for a default, because it has already found a matching case label. yes, and it continues the execution from the first matching case and correctly evaluates the following defaults, a

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Ferenc Kovacs
On Wed, Aug 13, 2014 at 2:58 PM, Rowan Collins wrote: > Ferenc Kovacs wrote (on 13/08/2014): > >> Btw. I've added a comment to https://bugs.php.net/bug.php?id=67757 as >> I've found some really weird behavior for multiple defaults and I think >> that it would be better to try to figure out and fi

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Ferenc Kovacs
On Wed, Aug 13, 2014 at 2:52 PM, Rowan Collins wrote: > Ferenc Kovacs wrote (on 13/08/2014): > >> not sure what do you mean here, multiple default cases can be reached the >> >> same way as any other duplicated case branch(as shown in my snippet in the >> mail you replied to). >> > > If you're ta

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Rowan Collins
Ferenc Kovacs wrote (on 13/08/2014): Btw. I've added a comment to https://bugs.php.net/bug.php?id=67757 as I've found some really weird behavior for multiple defaults and I think that it would be better to try to figure out and fix why do we pick the last default in the problematic snippet inst

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Rowan Collins
Ferenc Kovacs wrote (on 13/08/2014): not sure what do you mean here, multiple default cases can be reached the same way as any other duplicated case branch(as shown in my snippet in the mail you replied to). If you're talking about http://3v4l.org/eZdPU then those duplicates are definitely bei

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Ferenc Kovacs
On Wed, Aug 13, 2014 at 2:42 PM, Ferenc Kovacs wrote: > > > > On Wed, Aug 13, 2014 at 2:27 PM, Rowan Collins > wrote: > >> Ferenc Kovacs wrote (on 13/08/2014): >> >>> agree, and I thought about mentioning that, but I left that out, because >>> I'm not proposing to remove that ability (and I see

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Ferenc Kovacs
On Wed, Aug 13, 2014 at 2:27 PM, Rowan Collins wrote: > Ferenc Kovacs wrote (on 13/08/2014): > >> agree, and I thought about mentioning that, but I left that out, because >> I'm not proposing to remove that ability (and I see more use-cases for that >> as mentioned in my previous email) but stati

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Rowan Collins
Ferenc Kovacs wrote (on 13/08/2014): agree, and I thought about mentioning that, but I left that out, because I'm not proposing to remove that ability (and I see more use-cases for that as mentioned in my previous email) but stating that this patch would make an arbitrary distinction between th

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Alain Williams
On Wed, Aug 13, 2014 at 12:57:40PM +0200, Ferenc Kovacs wrote: > On Wed, Aug 13, 2014 at 11:42 AM, Andrea Faulds wrote: > > > Hi! > > > > On 13 Aug 2014, at 08:47, Ferenc Kovacs wrote: > > > > > and I also think that this isn't an important enough issue to warrant a > > BC > > > break (albeit th

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Ferenc Kovacs
On Wed, Aug 13, 2014 at 12:22 PM, Rowan Collins wrote: > Ferenc Kovacs wrote (on 13/08/2014): > > sorry to jump in this late, but I'm not sure that it is a good idea to >> only >> reject the multiple default blocks but keep the ability to have the same >> case multiple times: >> http://3v4l.org/

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Ferenc Kovacs
On Wed, Aug 13, 2014 at 11:42 AM, Andrea Faulds wrote: > Hi! > > On 13 Aug 2014, at 08:47, Ferenc Kovacs wrote: > > > and I also think that this isn't an important enough issue to warrant a > BC > > break (albeit this is the better kind of BC: probably doesn't effect too > > many people, and the

RE: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Christian Stoller
From: Andrea Faulds [mailto:a...@ajf.me] Sent: Wednesday, August 13, 2014 11:43 AM > > Hi! > > On 13 Aug 2014, at 08:47, Ferenc Kovacs wrote: > >> and I also think that this isn't an important enough issue to warrant a BC >> break (albeit this is the better kind of BC: probably doesn't effect to

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Andrea Faulds
On 13 Aug 2014, at 11:24, Peter Cowburn wrote: > > On 13 August 2014 10:56, Andrea Faulds wrote: > > > However, I tend to think that we should simply target php7 for any of > > these fixes. No need of endless arguing and keeps everyone happy. > > I’d rather we fix these in 5.7, which I’m a p

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Peter Cowburn
On 13 August 2014 10:56, Andrea Faulds wrote: > > On 13 Aug 2014, at 10:52, Pierre Joye wrote: > > > On Wed, Aug 13, 2014 at 11:42 AM, Andrea Faulds wrote: > > > >>> I could see > >>> where people would use it - there are reasons to, even if they are > poor in > >>> choice to do so. > >> > >> H

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Rowan Collins
Ferenc Kovacs wrote (on 13/08/2014): sorry to jump in this late, but I'm not sure that it is a good idea to only reject the multiple default blocks but keep the ability to have the same case multiple times: http://3v4l.org/eZdPU Multiple cases with the same value are a lot harder to prevent (if

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Andrea Faulds
On 13 Aug 2014, at 10:52, Pierre Joye wrote: > On Wed, Aug 13, 2014 at 11:42 AM, Andrea Faulds wrote: > >>> I could see >>> where people would use it - there are reasons to, even if they are poor in >>> choice to do so. >> >> How, exactly, could there ever be a use for having multiple default

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Pierre Joye
On Wed, Aug 13, 2014 at 11:42 AM, Andrea Faulds wrote: >> I could see >> where people would use it - there are reasons to, even if they are poor in >> choice to do so. > > How, exactly, could there ever be a use for having multiple default: sections > and ignoring all but one? This “feature” is

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Andrea Faulds
Hi! On 13 Aug 2014, at 08:47, Ferenc Kovacs wrote: > and I also think that this isn't an important enough issue to warrant a BC > break (albeit this is the better kind of BC: probably doesn't effect too > many people, and they will be clearly notified about the error at compile > time) so I vote

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Lester Caine
On 13/08/14 09:48, Ferenc Kovacs wrote: > I wanted to say that > and I also think that this isn't an important enough issue to warrant a BC > break in a minor version Reading between the lines this does seem to be more a problem for HHVM which has not copied the current operation properly. The que

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Ferenc Kovacs
On Wed, Aug 13, 2014 at 10:38 AM, Pierre Joye wrote: > On Wed, Aug 13, 2014 at 9:47 AM, Ferenc Kovacs wrote: > > On Wed, Aug 6, 2014 at 6:38 AM, Sara Golemon wrote: > > > >> https://wiki.php.net/rfc/switch.default.multiple > >> > >> 'Cause this code is silly (even if it had case blocks), but we

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Pierre Joye
On Wed, Aug 13, 2014 at 9:47 AM, Ferenc Kovacs wrote: > On Wed, Aug 6, 2014 at 6:38 AM, Sara Golemon wrote: > >> https://wiki.php.net/rfc/switch.default.multiple >> >> 'Cause this code is silly (even if it had case blocks), but we allow it: >> >> switch ($expr) { >> default: >> notExecuted(

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread James
Just saw the RFC today so I hadn't been able to comment on it until now.. If we are getting rid of it wouldn't it be better to emit an E_DEPRECATED per https://github.com/imnotjames/php-src/compare/switch.default.multiple-deprecated and then remove it in the next major release? This has been know

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-13 Thread Ferenc Kovacs
On Wed, Aug 6, 2014 at 6:38 AM, Sara Golemon wrote: > https://wiki.php.net/rfc/switch.default.multiple > > 'Cause this code is silly (even if it had case blocks), but we allow it: > > switch ($expr) { > default: > notExecuted(); > break; > default: > executed(); > } > > -- > PHP I

[PHP-DEV] Re: [STANDARDS] Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-06 Thread Adam Harvey
On 6 August 2014 12:32, Ferenc Kovacs wrote: > On Wed, Aug 6, 2014 at 8:35 PM, Sara Golemon wrote: >> > >> Did we agree on that? The lang spec was originally written to 5.6 to >> have a relatively stable target, but (in my mind at least) was meant >> to track master as we move the language forwa

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-06 Thread Ferenc Kovacs
On Wed, Aug 6, 2014 at 8:35 PM, Sara Golemon wrote: > On Wed, Aug 6, 2014 at 3:00 AM, Ferenc Kovacs wrote: > > I think dropping this behavior is a good idea, but I'm confused by the > > reasoning related to the langspec. > > This rfc targets php.next (which is a safe move as this has BC break >

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-06 Thread Sara Golemon
On Wed, Aug 6, 2014 at 3:00 AM, Ferenc Kovacs wrote: > I think dropping this behavior is a good idea, but I'm confused by the > reasoning related to the langspec. > This rfc targets php.next (which is a safe move as this has BC break albeit > would require some questionable code), but the langspec

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-06 Thread Rowan Collins
Lester Caine wrote (on 06/08/2014): On 06/08/14 11:16, Rowan Collins wrote: According to the bug report, HHVM also accepts multiple default blocks, but uses the first rather than the last. It's probably not worth implementing specific code there to take the last default label just in order to ad

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-06 Thread Lester Caine
On 06/08/14 11:16, Rowan Collins wrote: > According to the bug report, HHVM also accepts multiple default blocks, > but uses the first rather than the last. It's probably not worth > implementing specific code there to take the last default label just in > order to adhere to a 5.6 spec, but is wort

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-06 Thread Pierre Joye
On Wed, Aug 6, 2014 at 12:16 PM, Rowan Collins wrote: > Ferenc Kovacs wrote (on 06/08/2014): > >> Hi, >> >> I think dropping this behavior is a good idea, but I'm confused by the >> reasoning related to the langspec. >> This rfc targets php.next (which is a safe move as this has BC break >> albeit

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-06 Thread Rowan Collins
Ferenc Kovacs wrote (on 06/08/2014): Hi, I think dropping this behavior is a good idea, but I'm confused by the reasoning related to the langspec. This rfc targets php.next (which is a safe move as this has BC break albeit would require some questionable code), but the langspec was agreed to be

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-06 Thread Ferenc Kovacs
On Wed, Aug 6, 2014 at 6:38 AM, Sara Golemon wrote: > https://wiki.php.net/rfc/switch.default.multiple > > 'Cause this code is silly (even if it had case blocks), but we allow it: > > switch ($expr) { > default: > notExecuted(); > break; > default: > executed(); > } > > -- > PHP I

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-06 Thread Julien Pauli
On Wed, Aug 6, 2014 at 10:57 AM, Dmitry Stogov wrote: > yet another stupid implementation driven behavior :) > > +1 for master. > > Thanks. Dmitry. > Yep, definitely yes +1. Julien.Pauli

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-06 Thread Dmitry Stogov
yet another stupid implementation driven behavior :) +1 for master. Thanks. Dmitry. On Wed, Aug 6, 2014 at 9:31 AM, Sebastian Bergmann wrote: > Am 06.08.2014 um 06:38 schrieb Sara Golemon: > > https://wiki.php.net/rfc/switch.default.multiple > > Makes sense to me; +1. > > -- > PHP Internals

Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement

2014-08-05 Thread Sebastian Bergmann
Am 06.08.2014 um 06:38 schrieb Sara Golemon: > https://wiki.php.net/rfc/switch.default.multiple Makes sense to me; +1. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php