Code speed
Lars T. Kyllingstad
public at kyllingen.NOSPAMnet
Wed Apr 14 01:27:53 PDT 2010
Don wrote:
> bearophile wrote:
>> So far I've just given a light reading of the code. Notes:
>
>> - pow(x, 2) and sqrt(y) can be written as x ^^ 2 and y ^^ 0.5 (but you
>> have to import std.math anyway, because of a bug).
>
> That's not a bug. It's intentional. x ^^ y will probably always require
> import std.math, if y is a floating point number.
Really? Why is that? I find that kind of disappointing, I always
believed it to be a temporary solution.
I think the inconsistency with the other operators will make this a
major WTF for people new to the language. Why should a^^b require an
explicit import while a*b doesn't?
If the language made it possible to overload operators using free
functions, I wouldn't mind if opBinary!"^^"(float, float) was
implemented in std.math. The way it is now, it's a halfway built-in,
halfway library feature, and just seems halfway altogether.
-Lars
More information about the Digitalmars-d-learn
mailing list