Michael Morris wrote on 27/03/2015 12:03:
Rowan, I seriously, seriously doubt anyone would write PHP 7 compliant code that only takes advantage of ternary associativity, a feature that is only occasionally useful. If they can't take the hint from the parse errors arising out of the spaceship op and all the other stuff being added, they're too dumb to be programming and need to find another line of work.
I disagree. It would be perfectly easy for someone used to another language to be developing in a PHP 7 environment, use the idiom that's familiar to them (chained ternary operators as a kind of if-else expression), and see the results they're expecting, all without knowing it will work completely differently run in a PHP 5 environment.
The rest of the code might well run fine on PHP 5, since other than scalar type hints, there's really not that much that's changed. Do you really think every PHP library is suddenly going to find loads of uses for the spaceship operator that are so pressing they'll bump their minimum version requirement to 7.0?
Breaking loudly when moving between versions is always going to be better than behaving differently in a very hard to debug way.
While breaking backwards compatibility for its own sake is bad, avoiding it to keep a bug in the system is worse in my opinion. And again, this is a bug. If the way PHP associates could be used for something that would be different, but it can't. I honestly doubt any code even exists that takes advantage of the current behavior.
Yes, that's why I suggest non-associativity - very little current code will break, anyone trying to use the unavailable idiom will get instant feedback that it's not supported rather than unexpected behaviour.
And then later, when 8.0 rolls around, we can look at adding in the correct associativity, knowing for sure that no PHP 7 deployments will be affected.
Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php