Comment on A cursory look at meta-programming in NimparentComments−def-11yYou can do it a bit shorter and easier in Nim as well: import macros, strutils macro abcProcs(n: varargs[expr]): stmt = result = newStmtList() for c in n.children: result.add parseStmt("proc $1 = echo \"$1\"" % $c) abcProcs("A","B","C") proc execute(order: openarray[int], callbacks: openarray[proc]) = for i in order: callbacks[i]() execute([0,0,1,2,1,2], [A,B,C])
Comments
You can do it a bit shorter and easier in Nim as well: