Exponential operator
Lars T. Kyllingstad
public at kyllingen.NOSPAMnet
Fri Aug 7 03:50:25 PDT 2009
In the 'proposed syntax change' thread, Don mentioned that an
exponentiation operator is sorely missing from D. I couldn't agree more.
Daniel Keep has proposed the syntax
a*^b
while my suggestion was
a^^b
Neither of the natural candidates, a^b and a**b, are an option, as they
are, respectively, already taken and ambiguous.
"Why do we need this?" you say. "Isn't pow(a,b) good enough?" And yes,
pow(a,b) is just as good as mul(a,b) or div(a,b), but we don't use
those, do we? Exponentiation is a very common mathematical operation
that deserves its own symbol. Besides, bearophile has pointed out
several optimisations that the compiler can/must perform on exponential
expressions.
He also proposed that the overload be called opPower.
What do you think?
-Lars
More information about the Digitalmars-d
mailing list