On 26 June 2018 at 19:27, Nikita Popov <nikita....@gmail.com> wrote:

> 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.
>


I think this point should be highlighted: this is not just an unfortunate
legacy decision, it would be *really bad* if "break 2;" sometimes referred
to a different loop from "continue 2;"

Other languages don't have that problem, because they don't have the
"continue N" syntax.

I'm +0.5 on Nikita's proposal to make this an error - it can't mean
anything other than "continue with this switch statement", but that doesn't
actually mean anything. The error is effectively saying "Can't 'continue' a
switch, because it's not really a loop."

Perhaps rather than deprecating and removing it, we should simply raise a
Warning on its use: "Use of 'continue' to terminate switch; did you mean
'break', or to continue a loop instead?" In other words, "we've done what
you asked, but we think it might not be what you meant".

Regards,
-- 
Rowan Collins
[IMSoP]

Reply via email to