Compile time function execution...

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Fri Feb 16 14:54:04 PST 2007


Michiel wrote:
> Dave wrote:
> 
>>> Aggh, that's a compiler bug.
>>>
>>> int foo = square(5);
>>>
>>> does work. I knew I'd never get it right the first try :-(
>> Wait -- int foo = square(5); is supposed to CTFE? If so that'd be awesome.
> 
> I don't think so. If I'm not mistaken, D would do that at runtime at the
> moment.

It does that at runtime for variables in function-type scope. For global 
variables (as in the code posted) and IIRC aggregate members it 
determines initial values at compile time.



More information about the Digitalmars-d mailing list