Precedences of unary minus and dot operators

bearophile bearophileHUGS at lycos.com
Fri Nov 8 04:49:37 PST 2013


This is something that has come out of a thread I have opened in 
D.learn.

In the thread qznc has answered me:

> Operator precedence of "." is higher than unary minus.


That's right:


double foo(in double x) {
     assert (x >= 0);
     return x;
}
void main() {
     assert(-1.foo == -1);
}


Is this a good design of the operator precedences? Is this worth 
changing/fixing?

Bye,
bearophile


More information about the Digitalmars-d mailing list