ctfe reduction

StarGrazer via Digitalmars-d digitalmars-d at puremagic.com
Tue Mar 21 10:56:33 PDT 2017


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.






More information about the Digitalmars-d mailing list