On 01/01/16 12:52 AM, Shriramana Sharma wrote:
Using DMD 2.0.69.2, the following code:
extern (C) double sqrt(double x);
enum q = sqrt(4.0);
gives the error:
Error: sqrt cannot be interpreted at compile time, because it has no
available source code
But if I do:
import std.math;
enum q = sqrt(4.0);
There is no problem. So two questions:
1) Why exactly can't the compiler call a C function at compile time whereas
it can call a D function?
2) <same as above> ... which itself only in the end calls that very same C
function IIANM?
I see druntime/import/core/math.d l 91:
double sqrt(double x); /* intrinsic */
From what I've been able to tell, std.math have some special yucky
rules about it and intrinsics.
It will make it very hard to split std.math up.