Compile time function execution...

Walter Bright newshound at digitalmars.com
Thu Feb 15 14:15:00 PST 2007


Bill Baxter wrote:
> Walter Bright wrote:
>> ... is now in DMD 1.006. For example:
>>
> 
> Very nice!
> 
> A few questions:
> 1) You say recursion is allowed -- does it do proper tail recursion?

Tail recursion is a performance optimization, it has no effect on 
semantics, so it's not an issue for compile time execution.

> 2) Can't you just ignore 'synchronized' at compile time?

Pure functions (the kind that can be compile time executed) don't need 
to be synchronized anyway.

> 3) Would it be possible to add some sort of a version(CompileTime)? This 
> would make it possible for those who want to be *sure* the function is 
> only used at compile time to simply have it not exist as a runtime 
> call.  It could also be used to make slight modifications to functions 
> that one would like to use as both compile-time and run-time.  For 
> example if you want to have synchronized/try/catch/throw/writefln type 
> things in the runtime version.

Once more, there is never a situation where a function *might* or *might 
not* get executed at compile time. A function is *always* executed at 
runtime unless it is in a situation where it *must* be executed at 
compile time, such as in an initializer for a global.



More information about the Digitalmars-d mailing list