Hi,
How can I see the intermediate Nim code generated by templates? Sorry if this is trivial to answer, I couldn't find it easily.
Thanks, Peter
This is not easy, it's actually a bit tricky, because templates transform the compiler's internal AST; there never is intermediate code (in the code-as-text sense of the word) you can see. You can, however, look at individual template expansions as follows:
import macros
template foo(x: int): int = (bar(x), baz(x))
static:
echo getAst(foo(99)).toStrLit
echo getAst(foo(99)).treeRepr
Note that overloading will not have been resolved at this point, so if you use (say) x+1 somewhere, then you'll see lots of alternative choices for +.