This is very inefficient. The module cache should be globalized somehow. The REPL should have a current "dummy" file where the evaluations happen. All loaded / imported files should be treated as module imports.