Why does D change operator precedence according to C/C++ ?

2012-04-02 Thread deadalnix
Hi, I have a design question, or maybe it is a bug ? In D, == and != have the same precedence than comparisons operators. This isn't the case in C/C++ . Is it a design decision, made on purpose ? Is it a bug ? DMD implementation and http://dlang.org/expression.html both agree on that. I pers

Re: Why does D change operator precedence according to C/C++ ?

2012-04-02 Thread Andrea Fontana
Probably a good way to force parentesys usage and avoid subtle bugs... On Monday, 2 April 2012 at 10:01:20 UTC, deadalnix wrote: Hi, I have a design question, or maybe it is a bug ? In D, == and != have the same precedence than comparisons operators. This isn't the case in C/C++ . Is it a de

Re: Why does D change operator precedence according to C/C++ ?

2012-04-02 Thread Simen Kjaeraas
On Mon, 02 Apr 2012 12:03:14 +0200, deadalnix wrote: Hi, I have a design question, or maybe it is a bug ? In D, == and != have the same precedence than comparisons operators. This isn't the case in C/C++ . Is it a design decision, made on purpose ? Is it a bug ? DMD implementation and ht

Re: Why does D change operator precedence according to C/C++ ?

2012-04-02 Thread Stewart Gordon
On 02/04/2012 11:32, Simen Kjaeraas wrote: On Mon, 02 Apr 2012 12:03:14 +0200, deadalnix wrote: I have a design question, or maybe it is a bug ? In D, == and != have the same precedence than comparisons operators. This isn't the case in C/C++ . Is it a design decision, made on purpose ? Is it

Re: Why does D change operator precedence according to C/C++ ?

2012-04-02 Thread deadalnix
Le 02/04/2012 13:10, Stewart Gordon a écrit : On 02/04/2012 11:32, Simen Kjaeraas wrote: On Mon, 02 Apr 2012 12:03:14 +0200, deadalnix wrote: I have a design question, or maybe it is a bug ? In D, == and != have the same precedence than comparisons operators. This isn't the case in C/C++ . Is

Re: Why does D change operator precedence according to C/C++ ?

2012-04-02 Thread Andrea Fontana
Parentesys are needed only where there's ambiguity with precedence. a > b > c is ambiguous (we need parentesys) a == b > c is amibiguous (we need parentesys because == and > have the same precedence) a == b && c is not ambiguous ( && and == haven't the same precedence so we don't need paren

Re: Why does D change operator precedence according to C/C++ ?

2012-04-02 Thread Walter Bright
On 4/2/2012 5:04 AM, deadalnix wrote: So basically, the precedence doesn't matter because any situation where it matter is illegal anyway ? That's correct and neatly sums up the situation.

Re: Why does D change operator precedence according to C/C++ ?

2012-04-02 Thread deadalnix
Le 02/04/2012 15:49, Walter Bright a écrit : On 4/2/2012 5:04 AM, deadalnix wrote: So basically, the precedence doesn't matter because any situation where it matter is illegal anyway ? That's correct and neatly sums up the situation. Merci :D