Pow operator precedence

Mail Mantis mail.mantis.88 at gmail.com
Fri Jan 13 05:11:21 PST 2012


2012/1/13 bearophile <bearophileHUGS at lycos.com>:
> This is the third time I see people trip on power operator precedence:
> http://d.puremagic.com/issues/show_bug.cgi?id=7268
>
> Some people expect this:
> (-10 ^^ 2)
> To be 100 instead of -100
> (Note: Python here uses the same operator precedences.)
>
> Do you think it's worth (and possible) to help D programmers avoid this mistake in their code?
>
> Bye,
> bearophile

My fail =)
I guess that's the right behaviour, but for C++ programmer it's rather
confusing that binary operator precedes unary minus.
Don't see a way how such mistake may be helped to avoid though.


More information about the Digitalmars-d mailing list