|
|
|
|
|
by def-
4061 days ago
|
|
You 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])
|
|