Change your MSDscript implementation to use environments instead of substitution. The change includes
Env
class;PTR(Env)
as an argument to Expr::interp
;Expr::subst
method; andExpr::interp
tests.
For tests, it’s almost certainly a good idea to define empty
instead of writing new EmptyEnv()
many times. You may even want to declare empty
as a static variable of Env
in "env.h":
CLASS(Env) {
....
static PTR(Env) empty;
};
and initialize it "env.cpp" with
PTR(Env) Env::empty = NEW(EmptyEnv)();
Then, you can use Empty::env
anywhere that "env.h" is included.