On Sunday 06 March 2011 23:16:33 %u wrote: > > That's essentially the example that's been under discussion - though in > > this case it's a ref instead of > > a temporary for the lvalue. Regardless, it's context free because a * b is > by definition a variable declaration, not a call to the multiplication > operator. If you want it to use the multiplication operator, then use > parens: (a * b) = b. It's context free, because it just assumes one of the > two and it's _always_ that one, so there's no ambiguity. It is, _by > definition_, a variable declaration. > > Oh, I see. So is multiplication being special-cased in the grammar, or is > it part of a more general rule in the language?
It's not really that multiplication is being special-cased. It's that when something could either be a pointer declaration or a multiplicative expression, it's deemed to be a pointer declaration. Anywhere where it wouldn't be a pointer declaration, it's a multiplicative expression. > > Also, opMul is on its way to deprecation. binaryOp should be used for > > overloading the multiplication _Most_ of the old opX functions are going to be deprecated in favor of functions like opUnary and opBinary - which are far more flexible. You should probably read http://www.digitalmars.com/d/2.0/operatoroverloading.html - and if you can, reading TDPL (The D Programming Language by Andrei Alexandrescu) would be even better. - Jonathan M Davis