Why CTFE is context-sensitive?
Pierre Talbot
ptalbot**mustberemoved** at hyc.**thisto**io
Sun Jan 26 07:06:29 PST 2014
On Sunday, 26 January 2014 at 13:48:47 UTC, Timon Gehr wrote:
> On 01/26/2014 10:59 AM, Pierre Talbot wrote:
>> Hi,
>>
>> I was wondering why CTFE is context sensitive, why don't we
>> check
>> every expressions and run the CTFE if it applies?
>
> When does it apply?
According to http://dlang.org/function.html#interpretation
* initialization of a static variable
* dimension of a static array
* argument for a template value parameter
As shown in the examples:
int square(int i) {
return i * i;
}
void foo() {
writeln(square(4)); // run time
}
More information about the Digitalmars-d-learn
mailing list