How do I check if a function got CTFE?

H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Oct 2 12:11:32 PDT 2014


On Thu, Oct 02, 2014 at 07:04:56PM +0000, anonymous via Digitalmars-d-learn wrote:
> On Thursday, 2 October 2014 at 18:42:56 UTC, AsmMan wrote:
> >I was thiking the dmd compiler did CTFE without someone ask for this,
> >in the way as I've mentioned, checking for constant arguments +
> >function's purity and if all this is true, it did the CTFE rather
> >than generate code to compute it at run-time. In the case of it did
> >happen, I just wanted to know. It was my misunderstsooding how it
> >does works in dmd.
> 
> Yeah, that would be constant folding. The compiler is free to do that.
> It's just not called "CTFE" then.

CTFE grew out of constant-folding in dmd. In the dmd code, it is
essentially still just a constant-folder, albeit a superpowered one. :-P


T

-- 
It is of the new things that men tire --- of fashions and proposals and improvements and change. It is the old things that startle and intoxicate. It is the old things that are young. -- G.K. Chesterton


More information about the Digitalmars-d-learn mailing list