protected override void SetInitValues(LispEnvironment doEnv, List<Symbol> varSymbols, List<LispObject> varInitForms) { for (int i = 0; i < varSymbols.Count; i++) { var val = doEnv.Eval(varInitForms[i]); doEnv.AddBinding(varSymbols[i], val); } }
protected virtual void SetInitValues(LispEnvironment doEnv, List<Symbol> varSymbols, List<LispObject> varInitForms) { var varInitValues = varInitForms.Select(doEnv.Eval).ToList(); for (int i = 0; i < varSymbols.Count; i++) { doEnv.AddBinding(varSymbols[i], varInitValues[i]); } }
public override LispObject Eval(Cons body, LispEnvironment env) { var symbol = Car.Of(body).As<Symbol>(); var value = env.Eval(Car.Of(Cdr.Of(body))); env.AddBinding(symbol, value); return symbol; }
public override LispObject Eval(Cons defmacroBody, LispEnvironment env) { var symbol = defmacroBody.Car.As<Symbol>(); var lambdaList = Car.Of(Cdr.Of(defmacroBody)); var macroBody = Cdr.Of(Cdr.Of(defmacroBody)).As<Cons>(); var progn = Progn.Wrap(macroBody, env); var macro = new Macro(symbol.Name, lambdaList, progn, env); env.AddBinding(symbol, macro); return macro; }
private LispEnvironment GetLoopEnvironment(Action action) { var symbol = environment.Symbols.Intern("QUIT"); var builtin = new DelegateBuiltin(symbol.Name, () => { action(); return T.True; }); var loopEnv = new LispEnvironment(environment); loopEnv.AddBinding(symbol, builtin); for (int i = 0; i < stars.Length; i++) { loopEnv.AddBinding(stars[i], LispNull.Nil); } return loopEnv; }