On 26 March 2015 22:40:56 GMT, Alain Williams <a...@phcomp.co.uk> wrote:
>On Thu, Mar 26, 2015 at 10:31:00PM +0000, Rowan Collins wrote:
>
>> What I've always been annoyed by is the *precedence* of the operator
>- having to add brackets to mix it with string concatenation, etc -
>which it turns out to is the same in all sorts of languages.
>
>It is the ''all sorts of languages'' that is key here. The point is
>that PHP
>associativity for ?: is different from other languages and it is that
>that
>confuses and leads to bugs. What is right/wrong is not as important as
>all
>others doing it the other way.

This reply is competely out of context to the message you quote. Yes, I know 
that the *associativity* of the operator is wrong. My contention is that in 
practice, few people ever try to associate multiple instances of the operator, 
so few bugs result from it not working.

I contrasted this with *precedence*, particularly the precedence of an 
expression mixing the ternary operator with string concatenation, which is a 
much more common thing to do. But here, PHP is doing the "right" thing, if 
measured by other languages doing the same.

Personally, I'd be in favour of making the operator non-associative, thus 
breaking obviously if people try it. Changing it now would result in people 
using it in PHP 7, then running the code under PHP 5 and having obscure bugs to 
fix.

Regards,
-- 
Rowan Collins
[IMSoP]



-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to