No CTFE of function

ag0aep6g via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Aug 26 11:16:07 PDT 2017


On Saturday, 26 August 2017 at 16:52:36 UTC, Cecil Ward wrote:
> Any ideas as to why GDC might just refuse to do CTFE on 
> compile-time-known inputs in a truly pure situation?

That's not how CTFE works. CTFE only kicks in when the *result* 
is required at compile time. For example, when you assign it to 
an enum. The inputs must be known at compile time, and the 
interpreter will refuse to go on when you try something impure. 
But those things don't trigger CTFE.

The compiler may choose to precompute any constant expression, 
but that's an optimization (constant folding), not CTFE.


More information about the Digitalmars-d-learn mailing list