So, since - for better or for worse - I'm making some heavy use of templates and trying to reduce them & debug a few things here and there, I'm wondering how I could have a look into the final/generated Nim code after the templates have been processed.
(Perhaps, I'm missing something here and the templates don't actually generate Nim code, but C directly - the truth is I haven't looked this one up...)
You can use --expandMacro:templateName or use the following:
import std/macros
macro dumpTyped*(ast: typed): untyped =
result = ast
echo ast.repr
Thanks a lot!
For some weird reason, I have never managed to use --expandMacro - basically, I don't know what it's supposed to do, or - more precisely - where the expansion is to be shown... As I cannot simply spot it anywhere... :S
Perhaps, I'm missing something here and the templates don't actually generate Nim code, but C directly - the truth is I haven't looked this one up...
They generate Nim code and you don't have to look this up, it's basic knowledge about templates. Your beloved LaTeX works the same way, macro systems are pretty wide spread.