Meta-programming - examples

janderson askme at me.com
Sun Feb 11 03:30:34 PST 2007


Andrei Alexandrescu (See Website For Email) wrote:
> janderson wrote:
>>
>> ect...
>>
>>
>> ");
>> //Note that there should be a way to disable CheckCode in the general 
>> case to save compile time
> 
> I guess this is an obvious:
> 
> mixin(CheckCode(import "program.d"));

Now that I think about it, what about:

version (CheckCode) { mixin(checkCode(__FILE__)) }

//Rest of file
...

checkCode would probably make use of static asserts.  Is it possible to 
write a message to compiler output?  That would be a handy 
static-compilation tool.

Or maybe it could be in the unit-tests.  Actually you can probably do 
that in unit tests already even without mixin Expressions.

-Joel



More information about the Digitalmars-d mailing list