ctfe reduction

ag0aep6g via Digitalmars-d digitalmars-d at puremagic.com
Tue Mar 21 11:14:23 PDT 2017


On 03/21/2017 06:56 PM, 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)

e is not a manifest constant. X!"y" is presumably a compile-time 
constant, but that doesn't transfer to e.

> enum ee = X!"y";
> auto e = ee;

This shows that you can go from a static value to a dynamic value.

> But one can't do
>
> auto e = X!"y";
> pragma(msg, e);

But you can't go from a dynamic value to a static one. pragma(msg, ...) 
needs a static value, but e is dynamic.

> yet one can do
>
> enum ee = X!"y";
> auto e = ee;
> pragma(msg, ee);

You're not using e here. Did you mean to write `pragma(msg, e);`? That 
doesn't work for the same reason as the one above.

Aside: Your code doesn't involve any (visible) CTFE. CTFE is different 
from templates.


More information about the Digitalmars-d mailing list