> On Oct 19, 2019, at 3:05 AM, A.L.E.C <a...@alec.pl> wrote: > Imo, this would make more sense if fallthrough did something more, e.g. > allowing > > case X: > if (something) { > fallthrough; > } > something-else; > break; > case Y: ....
Interesting. What would you expect this to do? It is not intuitively obvious to me. > Going this way we could imagine that `fallthrough N` could allow skipping N > following > `case`s While I can see that as possible, I cannot think of any use-cases where I would even want to use it. Can you? Either way, I doubt I would never use it as IMO it could make for some very fragile code. > and `fallthrough default` jumping to the default section. Now I do like this, because it does not seem fragile to me and I could see it having some use-cases. > Then, don't we need a way to jump outside of the whole switch statement? Ah, > there's `goto` already. So, maybe extend `goto` somehow? Is that not what `break` is for? > Adding a no-op keyword does not make much sense to me. There are many no-op keywords already in PHP, such as typehints; they provide information to the PHP so it knows when to throw warnings and errors. The fact a potential feature is a no-op does not discredit it for me; instead I focus on the benefits the proposed feature can provide. In this case the benefits would be to alerting developer when they accidentally omit instructions to PHP of their intentions. And that seems to me to be something (almost?) everyone would want to see embraced? Clearly* PHPStan and many Linux developers would like the same[1][2]. > It might be not useful enough to justify a BC break. True, that is a concern. Not yet having experience working on PHP's parser I do not know how it is configured nor what about the design of PHP requires keywords unable to be used as constants, class names, function or method names. I know this is a tangent but that seems like a requirement designed to simplify the parser maybe, and not because of any logical requirement. So I assume whatever word was used for this would also have to be a reserved keyword? Or not? Can someone who knows why the parser requires reserve words speak to why? If it would have to be a BC break, then maybe we could overload break with `BREAK NEXT` instead of `FALLTHROUGH` to achieve the same goal? Or `CONTINUE NEXT`? I will say the term `FALLTHROUGH` is used in GoLang and the GCC compiler[2] so it might be the best for familiarity reasons, but BC might override that concern. Does anyone know how to quickly scan the top PHP projects to see how many would break if `FALLTHROUGH` were used? I know I could write a program to do it, but I have so many other programs to write... -Mike * Props to Bishop Bettini for these links [1] https://github.com/phan/phan/issues/2550 <https://github.com/phan/phan/issues/2550> [2] https://lwn.net/Articles/794944/ <https://lwn.net/Articles/794944/>