Comment #0 by bearophile_hugs — 2010-02-18T12:55:44Z
This doesn't compile and produces many complex error messages, the compiler can't find std.math.sqrt:
void main() {
double x = 5 ^^ 0.5;
}
Comment #1 by bearophile_hugs — 2010-04-14T13:43:14Z
With dmd 2.043 that program generates the error messages:
test.d(2): Error: must import std.math to use ^^ operator
test.d(2): Error: undefined identifier module test.std
test.d(2): Error: no property 'math' for type 'void'
Error: no property 'sqrt' for type 'int'
test.d(2): Error: function expected before (), not __error of type int
That can be improved a little (and they are too many).
Don has noted that the implementation of X^^Y when Y is a floating point reqires several function of std.math, and it's not an used frequently operation in D code (on the other hand X^^0.5 is more common, and it just requires sqrt, that doesn't require much code).
So it's possible to require the import std.math when a X^^FP is used. This is not nice, because it seems unnatural to require module imports to use a built-in operator, but it can be an acceptable compromise on a practical basis (if such compromise is adopted, the D documentation has to explain it.)