I would like to create a macro that gets as argument a function call. The macro should then replace the function call with a call of a modified function. But since my macro should not generally modify everything in the function, but just annotated statements, I would like to know how I can do such annotations. Sadly user defined pragmas seem to be not suitable. import macros {. pragma: myAnnotation .} proc foobar(i : int) : int = var j {. myAnnotation .} : int = i + 2 return i * 2 + j macro handlePragmas( arg: typed ): typed = echo arg[0].symbol.getImpl.repr discard handlePragmas: foobar(13)
the output of the macro here is just proc foobar(i: int): int = var j: int = i + 2 return result = i * 2 + j As you can see, the {. myAnnotation .} pragma is gone, and that is what I would need in my use case.