On Mon, Jun 25, 2018 at 7:53 AM, Stanislav Malyshev <smalys...@gmail.com> wrote:
> Hi! > > On 6/24/18 9:16 AM, Nikita Popov wrote: > > Hi internals, > > > > Another small deprecation for your consideration... > > > > https://wiki.php.net/rfc/continue_on_switch_deprecation > > Not sure I understand - what this is improving? Yes, continue being the > same as break is slightly surprising, but it doesn't seem to hurt > anything and I don't think it happens too often, so why change it at all? > This RFC resolves the following issue: a) In PHP "switch" is considered a looping structure, for this reason "break" and "continue" both apply to "switch", as aliases. For PHP, these are reasonable semantics, as PHP supports multi-level breaks. It would be very questionable if "break N" and "continue N" could refer to different loop structures just because there is a "switch" involved somewhere. b) On the other hand, other languages, such as C and C-based languages, use a different behavior, where "continue" refers to the enclosing loop. As these languages don't have multi-level breaks, these semantics are also reasonable. This leaves us in a position where "continue" means different things in PHP and in other syntactically similar languages, causing confusing for programmers familiar with them. This is solved by simply prohibiting the case that is ambiguous. This is not a loss for PHP developers (who use "break" instead of "continue" for switch statements anyway), but it is a gain for programmers from other languages not familiar with this detail (as they get an error pointing them to one of the correct alternatives). All of this is not a big issue, it's just removing a papercut. IIRC this was originally motivated by me seeing some bug reports about this behavior. Nikita