OK, I hope this time I understand what you want
This must be imported in your code example and the macro line defining _iter_
has to be commented out (supplying a closure iterator should also work):
import macros
# gets the name and bound symbol of a constant and does whatever is desired,
# even with constants of completely unknown type.
macro constCall*(name: string, value: typed): untyped =
result = newStmtList()
echo name, ": ", treeRepr(
if nnkSym == value.kind: value.symbol.getImpl
else: value
)
template constCallDef(name, value: untyped) =
constCall(name, value)
# converts constant entries into calls to constCall
macro myMacro*(body: untyped): untyped =
result = newStmtList()
for entry in body:
result.add getAst constCallDef($entry[0].ident, entry[1][0])
Alternatively, _constCall_ could be overloaded procs, possibly similar to what
you meant by "should utilize a separate generic proc".