lollipop icon indicating copy to clipboard operation
lollipop copied to clipboard

Handling imports-declarations

Open herrlax opened this issue 8 years ago • 1 comments

There is no obvious place to put the handling of import-declarations. A new datatype in Declaration in the AST would preferably be used, thus making the import available in the interpreter. A problem arises from this due to the fact that it's the REPL (loli.lp) that handles loading of files and not the actual interpreter.

herrlax avatar Apr 18 '16 14:04 herrlax

Handling modules could require quite a bit of work. It would be nice to do it, but other things are higher priority.

From the interpreters perspective a module could be viewed as an environment (map from identifiers to values). Each loaded module would be stored in memory as a separate environment, and you would have a map from module names to their environments. Then when loading a module you would have to add its environment to the start environment for that module. If the module has not already been loaded you would have to recursively load it first. So you would have a kind of meta-environment that maps module names to their environment. For the type checker you do the same thing but with type environments.

JonasDuregard avatar Apr 19 '16 12:04 JonasDuregard