[Issue 1475] allow to use intrinsic math functions (e.g. trigonometry) in CTFEs
Bill Baxter
dnewsgroup at billbaxter.com
Wed Sep 5 14:52:21 PDT 2007
BCS wrote:
> d-bugmail at puremagic.com wrote:
>> http://d.puremagic.com/issues/show_bug.cgi?id=1475
>>
>>
>>
>>
>>
>> ------- Comment #2 from wbaxter at gmail.com 2007-09-05 16:10 -------
>> Of course you can already do this by writing your own CTFE functions to
>> approximate those via Taylor series and the like. One of the first
>> CTFE demos
>> was a compile-time sqrt function.
>>
>> But yeh, the compiler has access to a better way to evaluate those
>> functions
>> than running what amounts to an interpreted language, so it would be
>> nice to be
>> able to access it. I can imagine some sort of plugin system where
>> you'd write
>> some D-code, compile it to a dll, and expose new compile-time
>> functions to the
>> compiler via that dll (much as you write extensions for other scripting
>> languages). And of course those initial CTFE compiler extensions
>> could be used
>> to compile further CTFE compiler extensions... and so on.
>>
>>
>
> As long as you aren't cross compiling, The compiler could take the
> version of the function it's going to put in the obj, plop it down in
> memory and run it. Why use DLLs?
Sure, implementation detail. :-)
There might be some value in having such CTFE libraries be
redistributable though? Probably gets in to security risk territory,
though.
--bb
More information about the Digitalmars-d-bugs
mailing list