about summary refs log tree commit diff stats
path: root/eval.lua
diff options
context:
space:
mode:
Diffstat (limited to 'eval.lua')
-rw-r--r--eval.lua15
1 files changed, 8 insertions, 7 deletions
diff --git a/eval.lua b/eval.lua index e926bc4..565ead5 100644 --- a/eval.lua +++ b/eval.lua
@@ -32,9 +32,13 @@ function eval.Proc (params, body, env)
32 p, a = p.cdr, a.cdr 32 p, a = p.cdr, a.cdr
33 end 33 end
34 pp.pp(self.body) 34 pp.pp(self.body)
35 return eval.eval( 35 local b = self.body
36 self.body, 36 local e = eval.Env(inner, self.env)
37 eval.Env(inner, self.env)) 37 while not isNull(b.cdr) do
38 eval.eval(b.car, e)
39 b = b.cdr
40 end
41 return eval.eval(b.car, e)
38 end, 42 end,
39 } 43 }
40 return setmetatable(v, mt) 44 return setmetatable(v, mt)
@@ -54,10 +58,7 @@ function eval.eval (x, env)
54 env[args.car] = eval.eval(args.cdr.car, env) 58 env[args.car] = eval.eval(args.cdr.car, env)
55 return nil 59 return nil
56 elseif op == "lambda" or op == "lam" then 60 elseif op == "lambda" or op == "lam" then
57 return eval.Proc( 61 return eval.Proc(args.car, args.cdr, env)
58 args.car,
59 Cons("begin", args.cdr), -- i don't like this
60 env)
61 elseif op == "if" then 62 elseif op == "if" then
62 assert(not isNull(args.cdr), "Malformed 'if'") 63 assert(not isNull(args.cdr), "Malformed 'if'")
63 local test, conseq, alt = 64 local test, conseq, alt =