Hello,
I am aware that `astToStr` returns string form of a Nim symbol or identifier.
I am looking to do the opposite of that.
I tried the below nim code but it fails with:
/home/kmodi/sandbox/nim/strToSymbol/t.nim(13, 12) template/generic
instantiation of `createProc` from here
/home/kmodi/sandbox/nim/strToSymbol/t.nim(8, 26) template/generic
instantiation of `strToSymbol` from here
/home/kmodi/sandbox/nim/strToSymbol/t.nim(4, 17) Error: undeclared
identifier: 'auto_foo'
Run
import std/[macros]
macro strToSymbol(s: static string): untyped =
result = ident(s)
template createProc*(procName: typed; body: untyped) =
const
procSym = strToSymbol("auto_" & procName)
proc `procSym`() =
body
createProc "foo":
echo "I am in foo"
auto_foo()
Run