what does CTFE get that external code gen dosn't?

Jarrett Billingsley kb3ctd2 at yahoo.com
Tue Jul 24 13:49:41 PDT 2007


"BCS" <ao at pathlink.com> wrote in message 
news:ce0a3343c2708c99c0f56ecb9e4 at news.digitalmars.com...
> If you can compile a program with CTFE then you can compile and run a D 
> program.
> If you can do that then you can run the same code and  have it generate .d 
> file and then compile that on the next pass.

How on earth would you do:

mixin(GenCode!(int)("x"));

char[] GenCode(T)(char[] name)
{
    return T.stringof ~ " " ~ name ~ ";";
}

Across the program execution boundary?  How do you pass that template param? 
Your CodeGen program can only take char[][], remember.

(This is a simple example which could be done with templates too, but 
imagine this function is much longer.)

Multiple compilations sounds like a terrible hack, and isn't nearly as 
simple or expressive as this. 




More information about the Digitalmars-d-learn mailing list