On 13 January 2012 21:31, bearophile <[email protected]> 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.
