Compile time function execution...
Walter Bright
newshound at digitalmars.com
Thu Feb 15 14:33:09 PST 2007
Michiel wrote:
> Walter Bright wrote:
>> It's the other way around. Functions are always executed at runtime,
>> unless they are in a context where a compile-time constant is
>> *required*, such as for global variable initialization or template value
>> arguments.
>
> I know that's how it's implemented now. But generally, it's a good thing
> if as much as possible happens at compile time.
Many functions could be executed at compile time, but should not be.
There's NO way for the compiler to figure this out. The only thing left
is for it to be explicit whether you want compile or run time execution,
and this is the way it is designed. There isn't any ambiguity - the
context determines it completely.
There's also an easy way to switch between the two, so I don't feel
there's a need for anything additional.
More information about the Digitalmars-d
mailing list