about summary refs log tree commit diff stats
path: root/load.lua
diff options
context:
space:
mode:
authorCase Duckworth2024-04-15 22:00:37 -0500
committerCase Duckworth2024-04-15 22:00:37 -0500
commit6c49847668e01d45cf56ec2b2e4fbf312957ee3d (patch)
treea4f85b67e41c7c03d0fa6830c187020d74157f65 /load.lua
parentRefactor type.character (diff)
downloadlam-6c49847668e01d45cf56ec2b2e4fbf312957ee3d.tar.gz
lam-6c49847668e01d45cf56ec2b2e4fbf312957ee3d.zip
Change names and hoist eval
read is unimplemented and load is buggy
Diffstat (limited to 'load.lua')
-rw-r--r--load.lua24
1 files changed, 21 insertions, 3 deletions
diff --git a/load.lua b/load.lua index 7f14207..db2651f 100644 --- a/load.lua +++ b/load.lua
@@ -15,9 +15,21 @@ local function schemeprint (x)
15 end 15 end
16end 16end
17 17
18local function handle_error (e) 18function core.environment.read (r)
19 local start = e:find(": ") 19 type.assert_arity(r,1,1)
20 return e:sub(start + 2) 20 error("unimplemented")
21end
22
23function core.environment.eval (r)
24 type.assert_arity(r,1,2)
25 local form = r[1]
26 local env = r[2][1] or core.environment
27 return eval.eval(form, env)
28end
29
30function core.environment.load (r)
31 type.assert_arity(r,1,1)
32 return m.load(tostring(r[1]))
21end 33end
22 34
23function m.load (filename, interactive) 35function m.load (filename, interactive)
@@ -29,6 +41,12 @@ function m.load (filename, interactive)
29 else 41 else
30 io.output():setvbuf("no") 42 io.output():setvbuf("no")
31 end 43 end
44
45 local function handle_error (e)
46 local start = e:find(": ")
47 return e:sub(start + 2)
48 end
49
32 repeat 50 repeat
33 if interactive then 51 if interactive then
34 io.stderr:write(interactive.prompt or "") 52 io.stderr:write(interactive.prompt or "")