On Friday, 8 November 2013 at 12:53:24 UTC, Daniel Kozak wrote:
On Friday, 8 November 2013 at 12:49:38 UTC, bearophile wrote:
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

From my POV this is good design. When I see:
assert(-1.foo == -1);
Is same for me as:
assert(-foo(1) == -1);

If I saw this, I would have to test it to be sure.. I feel it's in the same area as several post/pre increment/decrement in the same line.

Reply via email to