Closed john-science closed 10 years ago
This *.sl import
command would have to be native, in the evaluator. There I can use Python to .read()
a file into a string, evaluate it, and throw all definitions into the environment.
There are decisions to make here. Do I just naively parse the entire imported file? What if the file has many lines that return/print results? This is easier if it's all just def
s. What does Python do?
It seems to me that Python just imports names and definitions, and doesn't execute any particular code. The new names are then available via:
importfile.new_name
if you do import importfile
new_name
if you do from importfile import new_name
new_name
if you do from importfile import *
To start with, perhaps I could just import
performing like from importfile import *
.
And I won't start of worrying about creating a PYTHONPATH
, all imports will have to be given via local path.
Also, I will start by only import def
statements from other *.sl files.
This will be even easier than I thought. We already have a function interpreter.interpret_file
.
I need a way to import code held in other *.sl files. This is very important to being able to build larger programs.
Ideally, this should work well with importing *.py files (and libraries).