Re: CTFE with C functions not possible?

2016-01-01 Thread Shriramana Sharma via Digitalmars-d-learn
Rikki Cattermole wrote: > How exactly is a D version more bulky then C? > After all everything C can do, D can do with a very similar syntax. Source-code wise D is much leaner than C, obviously, but object-code wise it is *huge* even with dynamically linking Phobos: The binary size of

Re: CTFE with C functions not possible?

2016-01-01 Thread Rikki Cattermole via Digitalmars-d-learn
On 01/01/16 11:15 PM, Shriramana Sharma wrote: Rikki Cattermole wrote: Either port it to D and extern(C) it so it is accesible from other languages or not have CTFE support. I already wrote it in D, then I ported to C with much effort. The option to extern(C)-ing it didn't occur to me. :-(

Re: CTFE with C functions not possible?

2016-01-01 Thread Shriramana Sharma via Digitalmars-d-learn
Rikki Cattermole wrote: > Either port it to D and extern(C) it so it is accesible from other > languages or not have CTFE support. I already wrote it in D, then I ported to C with much effort. The option to extern(C)-ing it didn't occur to me. :-( Also, the D version is really much too bulky.

Re: CTFE with C functions not possible?

2015-12-31 Thread Rikki Cattermole via Digitalmars-d-learn
On 01/01/16 1:11 AM, Shriramana Sharma wrote: Shriramana Sharma wrote: What I desire to do is be able to call a C library from a D template like octal to compute a string at compile time. To be more explicit, I wrote a library in C since it's much leaner size-wise than the D code (although

Re: CTFE with C functions not possible?

2015-12-31 Thread Shriramana Sharma via Digitalmars-d-learn
Rikki Cattermole wrote: >> Is this possible or not? > > No, source is not available. Why, is it because the D compiler is already linked to the C library (and hence knows where the functions are located and such), but not to my library? I mean, I even gave -L-lmylib and all that, but of

Re: CTFE with C functions not possible?

2015-12-31 Thread Shriramana Sharma via Digitalmars-d-learn
Shriramana Sharma wrote: > What I desire to do is be able to call a C library from a D template like > octal to compute a string at compile time. To be more explicit, I wrote a library in C since it's much leaner size-wise than the D code (although admittedly much *much* more tedious to write

Re: CTFE with C functions not possible?

2015-12-31 Thread Rikki Cattermole via Digitalmars-d-learn
On 01/01/16 1:29 AM, Shriramana Sharma wrote: Rikki Cattermole wrote: You misunderstand, its hardcoded into the CTFE evaluator. That is what an intrinsic is. What do you mean hardcoded into the CTFE evaluator? Surely you aren't suggesting that the D compiler contains its own implementation

Re: CTFE with C functions not possible?

2015-12-31 Thread Rikki Cattermole via Digitalmars-d-learn
On 01/01/16 1:14 AM, Shriramana Sharma wrote: Rikki Cattermole wrote: Is this possible or not? No, source is not available. Why, is it because the D compiler is already linked to the C library (and hence knows where the functions are located and such), but not to my library? I mean, I even

CTFE with C functions not possible?

2015-12-31 Thread Shriramana Sharma via Digitalmars-d-learn
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:

Re: CTFE with C functions not possible?

2015-12-31 Thread Rikki Cattermole via Digitalmars-d-learn
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 =

Re: CTFE with C functions not possible?

2015-12-31 Thread Shriramana Sharma via Digitalmars-d-learn
Rikki Cattermole wrote: > You misunderstand, its hardcoded into the CTFE evaluator. That is what > an intrinsic is. What do you mean hardcoded into the CTFE evaluator? Surely you aren't suggesting that the D compiler contains its own implementation of the functions already implemented in libc?

Re: CTFE with C functions not possible?

2015-12-31 Thread Rikki Cattermole via Digitalmars-d-learn
On 01/01/16 1:05 AM, Shriramana Sharma wrote: Rikki Cattermole wrote: It will make it very hard to split std.math up. I have no desire to split std.math up. :-) I do though. What I desire to do is be able to call a C library from a D template like octal to compute a string at compile

Re: CTFE with C functions not possible?

2015-12-31 Thread Shriramana Sharma via Digitalmars-d-learn
Rikki Cattermole wrote: > It will make it very hard to split std.math up. I have no desire to split std.math up. :-) What I desire to do is be able to call a C library from a D template like octal to compute a string at compile time. Is this possible or not? -- Shriramana Sharma, Penguin

Re: CTFE with C functions not possible?

2015-12-31 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 31 December 2015 at 11:52:01 UTC, 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: