Re: [RFC] Deprecate and remove continue targeting switch
| From: | Stanislav Malyshev | Date: | Tue, 26 Jun 2018 22:44:09 +0000 |
| Subject: | Re: [RFC] Deprecate and remove continue targeting switch | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-102472@lists.php.net to get a copy of this message | ||
Hi!
> Do you mean that this code would be valid in both PHP 7 and PHP 8, but
> mean different things?
>
> while($outer) {
> while($inner) {
> switch($foo) {
> case 1:
> continue 2;
> }
> }
> }
>
I think this would be unacceptable, because WTF potential and subtle
code breakage that would result would be huge. If there are several
wrapped loops, it'd be almost impossible to detect that you're now
breaking a wrong loop. I think the only thing that could be changed is
"continue;" - without an argument - and the thing that should happen is
a notice that it may not do what you (might) think it's doing. If you
use something like "continue 2;" I would assume you know what you're
doing, this is a PHP-specific construct so it is reasonable to assume
you checked it does what you think it does.
--
Stas Malyshev
smalyshev@gmail.com