john-science / slowloris

A DIY-LISP.
5 stars 3 forks source link

Need a native "import" from other *.sl files #23

Closed john-science closed 10 years ago

john-science commented 10 years ago

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).

john-science commented 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 defs. 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:

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.

john-science commented 10 years ago

This will be even easier than I thought. We already have a function interpreter.interpret_file.