Very cool. The toImport allows any static string expression to be used as the
argument of the import.
I had seen the strdefine pragma but did not understand its purpose.
THANKS
Wow, I had no idea this is possible. :D
shorter version
const apple {.strdefine.} = "default_value"
template toImport(x: static[string]): untyped = import x
toImport(apple & "tools")
Run
import macros
const apple {.strdefine.} = "default_value"
macro toImport(x: static[string]): untyped = quote do: import `x`
toImport(apple & "tools")
Run
nim c -d:apple=new_value myproject
Run
Is there a way to use a static calculated string value as the argument of an
import statement?
For example:
> import LIB&"tools"
where LIB was a defined symbol from the nim compile command - perhaps:
> nim c -d:LIB=vector myproject.nim
so that myproject.nim would import vectortools.nim
Tryin