Rust updates

Walter Bright newshound2 at digitalmars.com
Wed Jul 11 11:31:23 PDT 2012


On 7/11/2012 11:00 AM, David Piepgrass wrote:
>> the logical bitwise operators have higher precedence. In C, x & 2 > 0 comes
>> out as x & (2 > 0), in Rust, it means (x & 2) > 0, which is more likely to be
>> what you expect (unless you are a C veteran).
> Oh, I can't tell you what a pet peeve PITA the C precedence is. Ugh! I know it's
> against D philosophy to change the precedence w.r.t. C, but how about a
> compromise: give a warning or error for "x&2 > 0", with error message: "add
> parenthesis around x&2 to clarify your intention."

   bool test(int x) { return x & 2 > 0; }

gives:

   foo.d(1): Error: 2 > 0 must be parenthesized when next to operator &


More information about the Digitalmars-d mailing list