when you cross macro boundary, not only typedesc transformed into NimNode, practically all args passed to macros will be transformed into NimNode, no matter it is an int, string, int literal, string literal, or a block of code/statements, all will be transformed into NimNode with specific kind. macro mymacro(x: int): untyped = echo x # perhaps failed to compile, x is not an int anymore, it is a NimNode of int literal
the same is also happened with T: typedesc, inside a macro, T is not a typedesc anymore, it is a NimNode of symbol. When you call template create(x: int, T: typedesc): untyped = T(age: x), it will not works because the template create expecting a T and constrained the type to typedesc not NimNode. while template create(x: int, T: untyped): untyped = T(age: x) will accept T wihout any specific type. when you have more than one macro with the same name, and they don't have varargs or untyped parameters, they can participate in macro overloading macro mymacro(T: typedesc): untyped macro mymacro(T: int): untyped macro mymacro(T: string): untyped etc