diff options
Diffstat (limited to 'eval.lua')
-rw-r--r-- | eval.lua | 10 |
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 | ||
3 | local m = {} | 3 | local m = {} |
4 | local core = require "core" | ||
5 | local type = require "type" | 4 | local type = require "type" |
6 | local assert_arity = require("util").assert_arity | 5 | local 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 = { | |||
133 | m.specials.lam = m.specials.lambda | 132 | m.specials.lam = m.specials.lambda |
134 | m.specials.def = m.specials.define | 133 | m.specials.def = m.specials.define |
135 | 134 | ||
136 | function m.eval (x, env) | 135 | function 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)) |