Thank you for the responses and code, I'm learning a lot about the macro system. Nice idea to use a pragma.
Testing the macro I was getting the compiler error: t.nim(11, 20) Error: invalid indentation I used treeRepr in the macro to debug the problem. It turned out I was putting the pragma in the wrong place. wrong: proc main {.tpub.} (p: int): string = right: proc main(p: int): string {.tpub.} = If you use the first way, a proc node is passed to the macro as expected but it does not contain any parameters.