Consider I have these modules which define the same functions (only
implementation differs):
-math_precise.nim
-math_optimal.nim
-math_fast.nim
Now I want to include them based on compile-time option.
I know I can use
const math {.strdefine.}: string = "precise" # default value
when math == "precise": # <-- here I hardcode possible values
import math_precise
elif math == "fast":
import math_fast
And then
nim c -d:math:fast
1) What if I don't want to hardcode modules names and just import by name? Like
const math {.strdefine.}: string = "precise" # default value
import "math_" & math # <-- Error: invalid module name :( I guess I should
play with macros?
2) Also, is there any way to import module by absolute location?
import /tmp/math_superfast
3) Will things work if I use "include" instead of "import"? (I know the
difference between them)