ctfe reduction

Stefan Koch via Digitalmars-d digitalmars-d at puremagic.com
Tue Mar 21 11:11:01 PDT 2017


On Tuesday, 21 March 2017 at 17:56:33 UTC, StarGrazer wrote:
> One problem with ctfe's is that the compiler is a bit ignorant.
>
> e.g.,
>
> auto e = X!"y";
>
> It is clear that e, when defined is a manifest constant(simply 
> because one can do)
>
> enum ee = X!"y";
> auto e = ee;
>
> But one can't do
>
> auto e = X!"y";
> pragma(msg, e);
>
>
> yet one can do
>
> enum ee = X!"y";
> auto e = ee;
> pragma(msg, ee);
>
>
> It seems that the compiler can be smart enough to figure this 
> out. It simply creates an intermediate analogous to the above. 
> Then we can do
>
> auto e = X!"y";
> pragma(msg, e)
>
> and the compiler is smart enough to make it work.
>
> There is no downside because it simply extends pragma to seem 
> like it works for the more general case. The compiler already 
> has to create the values internally so very little extra 
> overhead(just the placeholder for the intermediate step) is 
> required.
>
> When code building, this will save significant space.

Making the compiler smarter. Is often unwise;
Since smarter compilers tend to be much harder to debug.

Also I can confidently say this:

"CTFE performance will soon be no problem anymore."



More information about the Digitalmars-d mailing list