Compile time function execution...

BCS BCS at pathlink.com
Thu Feb 15 11:37:53 PST 2007


Walter Bright wrote:
> Ary Manzana wrote:
> 
>> A question: is there anyway the compiler can tell the user if a 
>> certain function can be executed at compile time? Those six rules may 
>> be hard to memorize and while coding sensitive code it would be great 
>> to ask the compiler "Is the function I'm writing can be executed at 
>> compile time?". Otherwise it's just a guess.
> 
> 
> The way to tell is it gives you an error if you try to execute it at 
> compile time and it cannot be.
> 
> Don't bother trying to memorize the rules, if you follow instead the 
> rule "imagine regular compile time constant folding and extend it to 
> functions" and you'll be about 99% correct.

I think the issue is where compile time and runtime are both allowed, 
but makes a *BIG* difference in performance.



More information about the Digitalmars-d mailing list