diff options
Diffstat (limited to 'eval2.lua')
-rw-r--r-- | eval2.lua | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/eval2.lua b/eval2.lua new file mode 100644 index 0000000..02444b8 --- /dev/null +++ b/eval2.lua | |||
@@ -0,0 +1,39 @@ | |||
1 | --- lam.eval | ||
2 | |||
3 | local eval = {} | ||
4 | local read = require "read" | ||
5 | local util = require "util" | ||
6 | local types = require "types" | ||
7 | table.unpack = table.unpack or unpack | ||
8 | |||
9 | local Environment = | ||
10 | function (inner, outer) | ||
11 | -- an Environment is really just a lua table between symbols and | ||
12 | -- values. They can be nested for uh, closure reasons or | ||
13 | -- something. TODO: figure out how this intersects with | ||
14 | -- Namespaces or Symboltables or whatever. | ||
15 | local mt = { | ||
16 | __type = "Environment", | ||
17 | __index = outer, | ||
18 | } | ||
19 | return setmetatable(inner, mt) | ||
20 | end | ||
21 | |||
22 | local Procedure = | ||
23 | function (params, body, env) | ||
24 | local proc = { | ||
25 | params = params, | ||
26 | body = body, | ||
27 | env = env, | ||
28 | } | ||
29 | local mt = { | ||
30 | __type = "Procedure", | ||
31 | __call = | ||
32 | function (self, ...) | ||
33 | end, | ||
34 | } | ||
35 | return setmetatable(proc, mt) | ||
36 | end | ||
37 | |||
38 | --- | ||
39 | return eval | ||