I was thinking about what would be necessary to allow NimScript to call any Nim function that is compiled into the binary that's running the NimScript. I imagine a world where NimScript can say "import zlib", and the interpreter will actually read and compile zlib.nim in an interpreted mode, but when it sees a proc definition, it short-circuits the compilation of the proc and instead fetches the compiled version of the proc out of the running binary. If zlib wasn't compiled into the binary, it would fail to load in the interpreter (because we cannot interpret importc functions), but if zlib was compiled in, it would work.
As I see it, we'd need:
Am I crazy to even consider this?
as a noob i shouldn't even consider a reply to your post, though only to answer the last question... did you see any one about this ? actually for real, if i were you i would install nim in a different folder maybe test x86 while original folder is x64 setup.
then with your knowledge which i don't even come close to, try convert an interpreted function into a compiled proc or what ever it is you think should be applied to original symbol table (yet again did not understand any of this) was i crazy to even answer this?
If I understand correctly, one would need to do something like this, but preloading other modules in the setup as well.
It would be great if one were to make this, for two reasons:
Actually, I wasn't just thinking of this being purely for C imports. I was also thinking of being able to use the compiled version of any proc, if that proc was already compiled into the binary.
With generics, I haven't seen how the compiler compiles them, but I imagine it probably compiles each instance separately. I could imagine having the interpreter expand the generic into a generic instance, and then check if that instance is compiled into the binary.
Big picture, I was imagining a development model where I can load a module into the interpreter, test it in a REPL, and when it's all ready, compile it. I used to do that in common lisp, it's a very efficient way to work.