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.lua10
1 files changed, 4 insertions, 6 deletions
diff --git a/eval.lua b/eval.lua index e3e21c3..867a704 100644 --- a/eval.lua +++ b/eval.lua
@@ -1,7 +1,6 @@
1--- lam.eval 1--- lam.eval
2 2
3local m = {} 3local m = {}
4local core = require "core"
5local type = require "type" 4local type = require "type"
6local assert_arity = require("util").assert_arity 5local assert_arity = require("util").assert_arity
7 6
@@ -122,9 +121,9 @@ m.specials = {
122 assert_arity(r, 3, 3) 121 assert_arity(r, 3, 3)
123 local test, conseq, alt = 122 local test, conseq, alt =
124 r[1], r[2][1], r[2][2][1] 123 r[1], r[2][1], r[2][2][1]
125 if m.eval(test) 124 if m.eval(test, e)
126 then return m.eval(conseq) 125 then return m.eval(conseq, e)
127 else return m.eval(alt) 126 else return m.eval(alt, e)
128 end 127 end
129 end, 128 end,
130 -- TODO: include, import, define-syntax, ... 129 -- TODO: include, import, define-syntax, ...
@@ -133,8 +132,7 @@ m.specials = {
133m.specials.lam = m.specials.lambda 132m.specials.lam = m.specials.lambda
134m.specials.def = m.specials.define 133m.specials.def = m.specials.define
135 134
136function m.eval (x, env) 135function m.eval (x, env) -- TODO: specify ENV on all calls
137 local env = env or core.env
138 if type.isa(x, "symbol") then 136 if type.isa(x, "symbol") then
139 if env[x] == nil then 137 if env[x] == nil then
140 error(string.format("Unbound variable: %s", x)) 138 error(string.format("Unbound variable: %s", x))