Re: Bug #1248: operator ? : has wrong associativity (has left, should be right).
| From: | Andi Gutmans | Date: | Thu, 25 Mar 1999 00:47:18 +0000 |
| Subject: | Re: Bug #1248: operator ? : has wrong associativity (has left, should be right). | ||
| References: | 1 2 3 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-4750@lists.php.net to get a copy of this message | ||
Hi,
I think that the ?: operator's associativity should be fixed in PHP 3.0 as
well as in PHP 4.0. It is pretty obviously a bug and I doubt fixing it
would cause people any grief. Usually people either don't do nested ?:'s or
they use parentheses (which you should have done too, as it's cleaner and
more readable :).
We would of course put a warning in the Changelog or README, so that people
know the behaviour has changed very slightly, but then again, I am pretty
sure no one has relied on this broken behaviour.
What do you guys think?
Andi
At 00:57 21/03/99 +0100, Peter Kundrat wrote:
>On Sun, Mar 21, 1999 at 01:34:16AM +0000, Zeev Suraski wrote:
>> This kind of depends on the language definition of PHP. It's true that
>> right-associativity would be compatible with C's associativity rules, but
>> that's all it is. I'm not sure if it's worth it to change this
>> associativity rule at this point; people may have relied on it, and it's
>> not a bug in any way.
>
>Well i might agree with the fact that now it is too late. Anyways
>it is kind of unfortunate to redefine the meaning (=associativity) of
>"standard" operator.
>
>> And on a related note, you should *really* be using
>> parentheses instead of relying on the precedence rules of any of the
>> non-trivial operators.
>
>Well i wouldnt agree here .. it is questionable what is trivial operator
>and what is not. I believe it comes from C so i expect it to work that
>way (same in perl and resemblance to perl is quite appealing).
>
>Of course it is legitimate to redefine any operator to
>behave in any way in a new language, but I believe it wasnt your (or whoever
>wrote language parser) intention to define it this way.
>
>Anyways, you are right .. at this moment there arent any options left.
>One way would be modify the parser to be able to set the associativity
>at run time and have it configurable in config file or runtime directive.
>This could lead to reduced portability but my guess is, that those who
>write nested ?: operators know it from previous languages so they have to
>use parents anyways so it wouldnt hurt them.
>
> Thanks for reply,
>
> Peter
>--
>Peter Kundrat
>kundrat@general-it.sk
>
>--
>PHP Development Mailing List http://www.php.net/
>To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
>For help: php-dev-help@lists.php.net
>
>
>
---
Andi Gutmans <andi@zend.com>
ICQ: 1568297
PGP: finger andi@vipe.technion.ac.il
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net