How about a 100% CTFE?

Don nospam at nospam.com
Wed Nov 9 17:13:56 PST 2011


On 07.11.2011 17:00, Gor Gyolchanyan wrote:
>> Well and somefunction ? It does modify teh value of a too. Is it executed before ? after ? What is the value at the end of all that ?
>
> Obviously it will be incremented first.
> The order is dependent of the rules by which the conditions are
> evaluated at compile-time. For example, the compiler will build a
> depth-first list of the import tree and evaluate code sequentially in
> each module.

This is not what it does now. At present, the order of compile-time 
evaluation is not defined; DMD currently does it vaguely in lexical 
order but that is planned to change in the near future. 'static if' and 
'mixin' will be evaluated in lexical order, before anything else is 
done. Afterwards, everything else will be evaluated on-demand.

Apart from the "static if/mixin" pass, compilation can proceed in 
parallel (though the current implementation doesn't yet do this) which 
means there's no ordering (multiple items may complete compilation 
simultaneously).

Allowing globals to be modified at compile time would destroy this.


More information about the Digitalmars-d mailing list