@Araq How can I do it with macros? getImpl returns the const's default value,
not the strdefined one:
import macros
const module {.strdefine.}: string = "math"
macro importconst(name: string): untyped =
let value = name.symbol.getImpl
echo "variable name: ", name.repr
echo "default value: ", $value
result = newNimNode(nnkImportStmt).add(value)
static:
echo "actual value: ", module
importconst(module)
# for -d:module=ropes it prints:
# variable name: module
# default value: math
# Hint: math [Processing]
# actual value: ropes
I encountered this problem a few times before, actually. What we need here is a
routine input of which are normal variables but output of which is code. But we
only have code2code (macros) and data2data (procs)...