So far, our interpreted language is only able do deal with expressions one by one. In a real programming language, we need to be able to store intermediate results in variables, and then later to look them up from the environment.
We will start by implementing the Environment
class (which can be found in diylisp/types.py
). Then we'll extend evaluate
to handle expressions using defined variables, and the creation of new variables with the define
form.
Run the tests, and get going!
nosetests tests/test_4_working_with_variables_and_environments.py --stop
In part 5 the environments we just implemented enable us to make lexically scoped functions.