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 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!
mvn -Dtest=VariablesTest test
In part 5 the environments we just implemented enable us to make lexically scoped functions.