You were on the right track, you can just use a macro for this and it makes it so much simpler. import std/[macros] macro createProc(name, body: untyped): untyped = result = newProc(ident("auto" & $name.baseName), body = body) createProc foo: echo "I am in foo" auto_foo() Run
- How to convert a string to an identifer or symbol? kaushalmodi
- How to convert a string to an identifer or symbol? ElegantBeef