I wrote a trivial utility template for generating code string. This provides some easiness and viewability of metaprogramming. (This is currently used in my adaptTo.)
http://github.com/9rnsr/scrap/blob/master/expand/expand.d Sample: ---- template GenFunc(string name) { mixin( mixin(expand!q{ int ${name}(){ return 10; } })); // result of expand! is: // q{`int ` ~ name ~ `(){ return 10; }`} } mixin GenFunc!("test"); // generates function "test" returns int unittest{ assert(test() == 10); } ---- expand!q{ codes... } parses D code string, and expands ${ expr } for embedding expr that is expression evaluated as string in compile-time. do you think? Kenji _______________________________________________ phobos mailing list [email protected] http://lists.puremagic.com/mailman/listinfo/phobos
