On Mon, Apr 22, 2019 at 5:28 PM Sara Golemon <poll...@php.net> wrote:

> On Tue, Apr 9, 2019 at 4:54 AM Nikita Popov <nikita....@gmail.com> wrote:
>
>> Inspired by Bob's recent RFC for concat precedence, I'd like to propose a
>> deprecation and removal of the left-associative behavior of ternaries.
>> Instead, explicit parentheses should be used:
>>
>> https://wiki.php.net/rfc/ternary_associativity
>>
>> This RFC makes nested ternaries without disambiguating parentheses an
>> error
>> in PHP 8 -- we might want to consider making them right-associative
>> instead, which is both useful and matches the behavior of other languages.
>>
>> Sorry, but I'm a "No" on this one.
>
> It'd be swell if PHP's ternary matched other languages, but it doesn't,
> and we have 20 years of code in the wild which has accepted that fact and
> moved on.  I don't see the benefit in breaking that code. Advise the use of
> parentheses and move on.
>

Can't say I understand your position here. Don't want to change the ternary
from left-associative to right-associative? I can understand that: Silent
behavior changes are always problematic. This is not what the RFC proposes
though.

20 years of code in the wild has not "accepted that fact and moved on". If
a left-associative ternary is used, it is almost certainly a bug. If people
use this structure by accident (because it is familiar from other
programming languages), I'd like them to get an error instead of having to
figure out why their obviously correct code is not working or, in the worse
case, just leave behind buggy code.

Nikita

Reply via email to