Re: Ternary associativity
| From: | Chuck Adams | Date: | Sat, 25 Jul 2020 15:26:09 +0000 |
| Subject: | Re: Ternary associativity | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-111183@lists.php.net to get a copy of this message | ||
On Fri, Jul 24, 2020 at 1:32 PM Rowan Tommins <rowan.collins@gmail.com> wrote:
> If anything, I would argue for making both of these into errors, if
> that's possible. I think the biggest risk with this kind of change is
> not existing code relying on the old behaviour, it is code relying on
> the *new* behaviour which is accidentally run on older versions of PHP.
I thought the proposal to turn unparenthesized use into a warning then
waiting for PHP9 to use the proper precedence was the right idea.
Nested ternaries with the proper precedence turn into lovely truth
tables, which isn't even an uncommon idiom in C. I'd really not like
to feed /r/lolphp ammo by requiring the parens in all cases and
continuing to break the ternary operator in comparison with every
other language that has it.
--c