Re: [RFC] Deprecate left-associative ternary operator

From: Date: Mon, 22 Apr 2019 15:28:09 +0000
Subject: Re: [RFC] Deprecate left-associative ternary operator
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-105330@lists.php.net to get a copy of this message
On Tue, Apr 9, 2019 at 4:54 AM Nikita Popov <nikita.ppv@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. -Sara

« previous php.internals (#105330) next »