pragma(msg,

Philippe Sigaud philippe.sigaud at gmail.com
Sun Jan 30 13:47:42 PST 2011


On Sun, Jan 30, 2011 at 19:15, Ellery Newcomer
<ellery-newcomer at utulsa.edu> wrote:
> doh.
>
> when I did something like
>
> enum string s = tct!(int,int);
>
> it just took it and didn't complain that it didn't know the value at compile
> time.

I think in this case, your asking for an enum string, er, 'propagates'
the compile-time-ness to tct!(int,int). Everything is calculated at
CT, because it's doable.
But when you used pragma(msg, someString), the compiler doesn't know
someString can be entirely known at CT.

So, there is a difference between

pragma(msg, tct!(T,U));

and

enum string s = tct!(T,U));
pragma(msg, s);

But if you indicate to the compiler you want the result of tct to be a
CT string, everything is resolved. So the easiest way is to put

enum string tct = ...

inside the template.

I spent some time building a CT regex engine in D. Having the
match/replace results shown with pragma instructions is fun, but I had
horrible moments trying to understand the interplay between
compile-time et runtime...

Philippe


More information about the Digitalmars-d-learn mailing list