<div class="gmail_quote">On 13 January 2012 16:09, Andrew Wiley <span dir="ltr"><<a href="mailto:wiley.andrew.j@gmail.com">wiley.andrew.j@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Fri, Jan 13, 2012 at 7:47 AM, Manu <<a href="mailto:turkeyman@gmail.com">turkeyman@gmail.com</a>> wrote:<br>
> On 13 January 2012 14:48, bearophile <<a href="mailto:bearophileHUGS@lycos.com">bearophileHUGS@lycos.com</a>> wrote:<br>
>><br>
>> This is the third time I see people trip on power operator precedence:<br>
>> <a href="http://d.puremagic.com/issues/show_bug.cgi?id=7268" target="_blank">http://d.puremagic.com/issues/show_bug.cgi?id=7268</a><br>
>><br>
>> Some people expect this:<br>
>> (-10 ^^ 2)<br>
>> To be 100 instead of -100<br>
>> (Note: Python here uses the same operator precedences.)<br>
>><br>
>> Do you think it's worth (and possible) to help D programmers avoid this<br>
>> mistake in their code?<br>
><br>
><br>
> I would certainly have made this mistake if I tried it. And knowing this<br>
> information will not cause me to do it properly, it will simply make me<br>
> question my code, and become very suspicious every time I ever use the<br>
> operator (ie. I will never understand the proper precedence, I don't think<br>
> it makes sense).<br>
> I'm fairly amazed it's not the other way around... what's the logic behind<br>
> this?<br>
<br>
</div></div>The logic is that the precedence in the language matches the<br>
precedence of a written equation.<br>
</blockquote></div><br><div>But the operator looks nothing like the written equation... nothing at all like the written equation.</div><div>Perhaps D could support the unicode characters '<font face="arial, helvetica, sans-serif"><font size="4">²</font>' '<font size="4">³</font>' or '<font size="4">ª</font>' as kinda handy operators. But to me, the operator looks NOTHING like maths notation, and it would never </font><span style="font-family:arial,helvetica,sans-serif">have</span><span style="font-family:arial,helvetica,sans-serif"> </span><span style="font-family:arial,helvetica,sans-serif">occurred to me that the operator was trying to emulate maths notation (and by extension, its precedence rules).</span></div>
<div><font face="arial, helvetica, sans-serif">I'd be interested to see a poll, and how many people see it one way or the other...</font></div>