Hello bearophile,
Ben Hanson:
Can you output source code at compilation time and have D compile it,
or do you use a load of recursion like C++ TMP?
This can be done with string mixin. You can use compile-time
evaluation to build a string of code, and the mix it in somewhere, the
compiler will compile it. It's a dirty thing, but unless D3 gets
macros, it's the thing to be used. You can use it to build a string of
asm code too, because it's part of D syntax.
OTOH, and IHMO it should be avoided where you can, kinda like goto. (For
one things, forget having usable line numbers in your error messages.) You
can often get a lot done with static if, tuple foreach, const values feed
to boilerplate code and the like with just a scattering of one or two line
mixins stuffed in the middle.
Bye,
bearophile
--
... <IXOYE><