On Wednesday, 17 July 2013 at 05:29:26 UTC, H. S. Teoh wrote:
On Wed, Jul 17, 2013 at 05:27:34AM +0200, JS wrote:
With heavy ctfe code generation usage is it possible to have
the d
compiler output the source code after all mixin templates have
been
"used"? This way it is easier to visually check for errors in
the
generated code.
I imagine one could use pragma in a "special way" to do this
but I
was hoping for something more direct.
Yeah I've been looking for this too. Once you have templates
and mixins
nested deeply enough, it can be near impossible to figure out
just
exactly *what* is being compiled at the end of it all.
Though I suppose the common approach is to generate a string
representing the code, and then using mixin(str) to compile it;
this
lets you use pragma(msg) to output str and thereby see what
exactly is
being compiled. But this may not be possible in some cases.
T
That is what I use but at some point it will become worthless. I
was thinking it may be possible to optionally pragma the code
depending on a symbol like __codegen, which would then trigger
all the appropriate pragma's, the problem is, the output will be
a mess because of the nesting(code duplication). Only the most
outside mixin's pragma needs to be triggered, the one directly
used in the code(not inside another template).