Pow operator precedence

Manu turkeyman at gmail.com
Fri Jan 13 11:43:59 PST 2012


On 13 January 2012 21:31, bearophile <bearophileHUGS at lycos.com> wrote:

> > What I wonder is why this operator is necessary at all?
>
> It's not necessary, like most other features in a language, like for
> loops. But it's handy and very useful, I am now using one power operator
> about every 40 or 50 lines of D2 code.
>
> Instead of writing:
> result = (complex expression) * (complex expression);
>

What are you working on if I may ask? I do tend to write a lot of very
maths-intensive code (physics, rendering, lighting), and I almost never
find myself using any sort of pow, other than ^2, which I'm perfectly happy
to type x*x.

Or:
>
> const aux = complex expression;
> result = aux * aux;
>
> You write:
>
> result = (complex expression) ^^ 2;
>

I'm more than happy with aux*aux, in fact, I think I prefer it (probably
just through habit). Though I do sort of see your point.


> And it gets better with cubes.
>

Realistically, how often do you cube? It's extremely rare in my experience.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120113/908e97c8/attachment.html>


More information about the Digitalmars-d mailing list