Pow operator precedence
bearophile
bearophileHUGS at lycos.com
Fri Jan 13 11:31:25 PST 2012
Don:
> Originally it worked the other way, but bearophile complained about it,
> so it got changed to this way <g>.
If I port Python code to D I prefer the current design. I have opened this thread to see if there are ways to mitigate some of the future problems caused by that :-)
Of my past design decisions about D I regret of suggesting Walter the name "immutable". Its meaning is very clear and it's the correct word, but it's a bit too much long to type, and I am using it often :-| (but less often than const, fortunately). Maybe "imm" or "immu" was better :-)
---------------------
Manu:
> 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);
Or:
const aux = complex expression;
result = aux * aux;
You write:
result = (complex expression) ^^ 2;
And it gets better with cubes.
I think ^^ operator is currently lacking one overload still, it's discussed a bit in one of the Bugzilla answers written by Don, I think regarding BigInts.
--------------
Mail Mantis:
> Maybe it would be good to always require explicit parenthesis in such expressions?
Is this wise and good?
Bye,
bearophile
More information about the Digitalmars-d
mailing list