On Wed, Aug 13, 2014 at 3:55 PM, Rowan Collins <rowan.coll...@gmail.com> 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; >> 6. } >> 7. $state = SITDOWN; >> 8. case SITDOWN: >> 9. if(!sitdown()){ >> 10. break; >> 11. } >> 12. $state = SIPWHISKEY; >> 13. case SIPWHISKEY: >> 14. sipwhiskey(); >> 15. } >> 16. } >> >> >> >> where you modify the switch variable in one case and fall through into >> another. >> as I mentioned I don't have a reasonable use-case for multiple defaults, >> but I can see some for multiple case labels in general, and I don't think >> that it is better to have different behavior for case and default in this >> regard. >> > > > The assignments to $state in that code do not make any difference to > execution, control simply flows forwards whenever there is no "break". > > $state is only tested once, to select the initial label to jump to, so no > amount of reassigning it, or adding duplicate labels, can ever cause a > second jump. > > I'm tempted to write a PHP script that emulates the switch execution by > building a set of if and goto statements, which might make some of this > behaviour clearer (not just for this discussion, but for other confusion > I've seen elsewhere), but I don't have time right now. > yeah, and that is a documented behavior, I've just had a momentary brain-fart here (which is funny considering that at one point I even wrote a codesniffer rule for generating warnings for fall-through case statements without an explicit comment). thanks again for pointing that out. and sorry for the noise. ps: I still hold onto my no vote, even thought it is a small BC break, it is still a BC break, I wouldn't consider the current patch as a bugfix(and even thought that the spec documented this as not a valid syntax hhvm still supported it, ableit picking the first default when there are more than one) , I would prefer having it E_DEPRECATED first in 5.next and we can remove it in 7.0. -- Ferenc Kovács @Tyr43l - http://tyrael.hu