You should be able to just write some code to add to a runtime seq or table.
Something like this:
import macros
# no need for "{.compile.}"
var registeredProcs = newSeq[string]()
macro remote*(n: untyped): untyped =
let procName = n[0]
# This template will add the procs to whatever runtime variable you want,
# so you can put a table inside here as well :)
template addRegProc(procName, n) =
registeredProcs &= procName
echo registeredProcs
n
result = getAst(addRegProc($procName, n))
proc square(x: float): float {.remote.} = x * x
proc cubic(x: float): float {.remote.} = x * x * x
proc genericCall*(id: string, x: float): float =
echo "looking up ", id, " in ", registeredProcs
for funcId in registeredProcs:
if id == funcId:
echo "would call id: ", funcId
# locally in this module it works fine
discard genericCall("square", 1)
discard genericCall("cubic", 1)
With that code, your user.nim file compiles and runs as expected.