Hi Bishop, I'm not the proposer, but would like to answer your questions anyway.
On Fri, 18 Oct 2019 at 04:14, Bishop Bettini <bis...@php.net> wrote: > Do you envision this token accepting an optional argument, as break does, > to fall-through multiple nesting levels? Eg: > > <?php > $x = $y = $z = 1; > switch ($x) { > case 1: > switch ($y) { > case 1: > switch ($z) { > case 1: fallthrough 3; > case 2: echo 'z2'; > } > } > break; > case 2: echo 'x2'; break; > } > ?> > I think we should keep it simple - we can always add more features later if a real need reveals itself. I note that the Go version linked to explicitly forbids the use of "fallthrough" in a conditional, and a multi-level fallthrough is effectively the same thing: the control flow in your example is something like if ( $y==1 && $z == 1 ) { fallthrough; } else { break; } I would have thought that by the time you've got nested switch statements with conditional fallthrough on multiple levels, the code is going to be very hard to reason about, so unless there's a key use case, I'd leave the complexity out of the language. There might be use cases for single-level conditional fallthrough, but I'd lean towards defining it as Go has: as a marker at the end of the case block only. By far the most common use of it I've seen is like Mike's: case x: additional pre-processing fallthrough case y: shared processing break > What do you envision the result of indicating fall-through to no subsequent > case? Eg: > > <?php > switch ($x) { > case 1: fallthrough; > } > I think it would be perfectly fine for this to do nothing. Currently you can write both switch ($x) { case 1: } and switch ($x) { case 1: break; } In general, I really like this idea; I've always wished switch worked this way. Regards, -- Rowan Tommins [IMSoP]