Precedences of unary minus and dot operators

Artur Skawina art.08.09 at gmail.com
Fri Nov 8 08:01:24 PST 2013


On 11/08/13 14:59, bearophile wrote:
> Dicebot:
> 
>> Yes it is expected and reasonable to me. Otherwise you'd need brackets for every expression like this: `-aggregate.field`
> 
> For me it's weird... :-)

The weirdness does not really come from the op precedence, but UFCS and
literals. Ie there's nothing weird with 'f(-3.14)', nor '-pi.f()'; it's
first when it's written like '-3.14.f()' that it becomes very unintuitive.
Somebody asked recently about D gotchas -- this is one, and it will cause bugs.
Most people will not start out with '(-3.14).f()'...

artur


More information about the Digitalmars-d mailing list