On 27 June 2018 at 16:14, niel <spam-f...@blueyonder.co.uk> wrote:

> On 26/06/18 21:49, Rowan Collins wrote:
>
>> On 26/06/2018 20:28, niel wrote:
>>
>>> On 24/06/18 17:16, Nikita Popov wrote:
>>>
>>>> Hi internals,
>>>>
>>>> Another small deprecation for your consideration...
>>>>
>>>> https://wiki.php.net/rfc/continue_on_switch_deprecation
>>>>
>>>> Regards,
>>>> Nikita
>>>>
>>>> IMO the proposed illustrations will lead to as much, if not more, WTF
>>> from other language users as current behaviour. Why? Because the programmer
>>> still has to account for the 'switch' in how continue works. This will just
>>> cause a BC problem for older code without adding anything for people new to
>>> PHP.
>>>
>>> My suggestion, is to make the break (no pun intended) be clean.
>>> Deprecate use of continue from usage to escape switch completely in next
>>> PHP, then remove that functionality in PHP 8.
>>>
>>>
>> Do you mean that this code would be valid in both PHP 7 and PHP 8, but
>> mean different things?
>>
>
> How is that different to the illustrations provided? That code is valid in
> PHP 7.0-7.3 but will have different meaning in 7.3.
>


In the proposal, the code is valid in all versions of PHP up to and
including 7.3, *and represents the same algorithm in all versions*. The
only difference would be the side-effect of issuing an additional
deprecation notice; that's not "a different meaning". In PHP 8, under
Nikita's proposal, the code would not be valid at all.

The RFC reiterates this under "Unaffected PHP Functionality":

> The meaning of continue and break inside switch never changes, some cases
are just forbidden.

In contrast, if we make the continue that previously referenced the switch
now reference the loop, the same code will work in PHP 8, but now
*represent an entirely different algorithm*.



>
> Ultimately, I was trying to express what Zeev said better:
>
> Ultimately - even after this change, C developers won't be able to use the
>> C semantics they're used to, as (e.g. in the example in the RFC) -
>> 'continue;' won't work as they'd expect - and they'd have to acquaint
>> themselves with 'continue 2;'.  It's true that if we 'force' them to
>> acquaint themselves with multi-level loop control structures there's
>> reduced 'continue;' erroneously.  But unless this is really A Thing, as in,
>> something pretty common - I think the mess involved with forcing people who
>> have working code to try and (a) understand the change, and (b) understand
>> their (potentially quite ancient) code flows may outweigh the benefits.
>>
>
>

If we change the behaviour, rather than removing it, we solve the first
problem (C developers will get the semantics they're used to) but we will
make the second problem worse (people with working code will need to
understand why it now does something different).

Regards,
-- 
Rowan Collins
[IMSoP]

Reply via email to