Implement user-side module loading and module caching
srijan-paul opened this issue · comments
Currently, only standard library modules can be loaded and cached.
We want to be able to load modules from anywhere within the current directory.
Note:
- Calling
import
returns a table. - There are 2 kinds of modules
2.1. Native modules written in C++ and exposed via the Vyse API.
2.2. Modules written in Vyse (more common). - Native modules are a bit harder to deal with, because we have to make sure we keep a handle to the shared library around in memory. Loading the same module multiples must not create new handles, that counts as a memory leaks. Whether the handles should be garbage collected when the contents of a module die is still undecided.
- Vyse modules are easier, we need to read some text from a file somewhere in the filesystem and the VM does the rest.
I feel further brainstorming on this topic will help come up with more concrete ideas (especially with 3).
This could be done in 2 PRs, one that loads vyse modules and one that loads native ones.