Compile time function execution...

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


Reiner Pope wrote:
> Walter Bright wrote:
>> Michiel wrote:
>>> * the syntax for functions to be executed at compile time isn't the
>>> nice-and-simple D syntax, but the template-syntax. And in another thread
>>> you yourself have mentioned why that's not optimal. I agree.
>>
>> I don't think eval!(expression) is an undue burden. It's hard to 
>> imagine how any other syntax would look better.
> But in many situations, you could view compile-time function execution 
> simply as a high-level optimization, an extension on 'inline'. Why, 
> then, does it make sense to require explicit eval!() annotations, when 
> it clearly doesn't make sense to do this for inline?

You can completely ignore and omit the eval!() and your code will run 
just fine. The eval!() is only for those who wish to do some more 
advanced tweaking.


> Viewing this as a more complex extension to inlining, I think the 
> correct approach is to allow explicit annotations for 'only at runtime' 
> and 'only at compile time'

I just don't see what is to be gained by this (and consider the extra 
bloat in the language to provide such annotations). The language already 
gives complete, absolute control over when a function is executed. Can 
you give an example where such annotations improve things?

> and have the rest decided according to a 
> compiler switch, eg -pre-eval



More information about the Digitalmars-d mailing list