OR, better yet:
mixin MyMixin
{
foreach(i; 0..10)
MyMixin ~= "writeln(" ~ to!string(i); ~ ");\n"'
}
And this could be printed out as a pragma(msg, ...) or into a .log file or anywhere else. This way it's easy to see what did end up being mixed in.
I bumped into this today actually. It's certainly a nice idea.
I see a lot of noise about said AST macros...
I understand the idea, but I have no idea how it might look in practice. Are there any working proposals?
I find myself using mixins waaaay too much. They're just too convenient, and enable lots of things that just aren't possible any other way. But I always feel really dirty! It can be so tedious dealing with all the string mess.