OK, so I have a rather simple question.
Let's say I have some code with various import statements and also compile-time logic.
Can I import different modules on demand?
Example:
static:
let myModule {.compileTime.} = "someModule"
import myModule
when <some condition>:
import the/module
else:
import other/module
Thanks a lot for the reply(ies).
Looks exactly like what I need.
How do I convert it so that it supports something like?
importLib("Somelib")
# converted to:
# import library/Somelib as SomelibLib
I'm not very familiar with macro syntax, but unless you have some suggestion I guess I'll have to read up on that :)
Well, for anyone that might be interested, here's how I managed to do it:
https://github.com/arturo-lang/arturo/blob/master/src/vm/vm.nim#L33-L83
nnkImportStmt is enum value of NimNodeKind. You need to call nnkImportStmt.newTree.
There are a bunch of convenience procs in the macros module:
as well as many others