Pow operator precedence

Manu turkeyman at gmail.com
Fri Jan 13 10:02:43 PST 2012


On 13 January 2012 17:56, Don Clugston <dac at nospam.com> wrote:

> On 13/01/12 14:47, Manu wrote:
>
>> On 13 January 2012 14:48, bearophile <bearophileHUGS at lycos.com
>> <mailto:bearophileHUGS at lycos.**com <bearophileHUGS at lycos.com>>> wrote:
>>
>>    This is the third time I see people trip on power operator precedence:
>>    http://d.puremagic.com/issues/**show_bug.cgi?id=7268<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?
>>
>>
>> I would certainly have made this mistake if I tried it. And knowing this
>> information will not cause me to do it properly, it will simply make me
>> question my code, and become very suspicious every time I ever use the
>> operator (ie. I will never understand the proper precedence, I don't
>> think it makes sense).
>> I'm fairly amazed it's not the other way around... what's the logic
>> behind this?
>>
>
> Originally it worked the other way, but bearophile complained about it, so
> it got changed to this way <g>.
>

Well... he should obviously be shot!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120113/f4d555b4/attachment-0001.html>


More information about the Digitalmars-d mailing list