Le 10 avr. 2019 à 21:21, Stanislav Malyshev smalyshev@gmail.com a écrit :
Hi!
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
Please, let's not mess with language syntax and require people to
rewrite their code just because suddenly after 20 years of existence in
the language we feel maybe the precedence should be different. I
literally can't think of a single case where it would improve anyone's
life in any substantial way.
I bet that more than one developer has once written <?php cond1 ? value1 : cond2 ? value2 : value3 ?>, and later has wasted a nontrivial amount of time in order to understand why they got some wrong result. So, definitely, making that trap a syntax error is a real tangible improvement of the language.
If you wanted to use parentheses, you can
do it now - you can even have it enforced by code analyzer if you wish
so, in your private code base.
A language that requires their users to use a code analyser (or to read the manual thoroughly before starting to code) in order to keep their sanity, well, ... has a problem.
But I can easily imagine dealing with
tons of deprecation warnings (which usually break CI unit tests and
wreak general havoc) or even worse, useless errors, in existing code,
which would become broken for no reason
As I can’t imagine a case where someone would have taken advantage of the current left-associativity semantics, I can’t imagine either someone dealing with “a ton of deprecation warnings” because of that. But TBH, my imagination is sometimes very selective. However, what I can imagine, is that hidden bugs will be revealed as a side-effect of those deprecation warnings, and time will be taken to understand and correct them.
—Claude
but... honestly, I don't even
know how to finish this phrase, I can't even think of a single reason I
could explain to anybody why their code would no longer work in 8.0.
I understand 8.0 is a good target for breaking things. But that doesn't
mean we have to do it as much as possible.
And this absolutely doesn't mean we need to get 7.4 to break things (and
yes, deprecation warning is breaking things, in most cases).
Stas Malyshev
smalyshev@gmail.com