f18d690
Branches > main > f18d690 > files
Add require special form
Commit: f18d690ba426b6b1140fe08fb1b104bccd4c506c
Parent: 5b1f6f9
1 changed file:
org/faddle/lang/eval.lua view file
@@ -60,6 +60,7 @@ local QUOTE = intern("quote") local FN = intern("fn") local LET = intern("let")+local REQUIRE = intern("require") -- Should eventually be in core/boot ofc they're just here now so I can test functions before figuring out modules local temp_vars =@@ -125,6 +126,12 @@ end end +local function req(form)+ local mod = second(form)+ assert(type(mod) == "string")+ return require(mod)+end+ -- So is this what loads core and alises? local function create_env(mod_name) local env = {current_module = mod_name}@@ -136,11 +143,12 @@ if is_list(form) then if count(form) == 0 then return form end local f = first(form)- if f == QUOTE then return second(form) end- if f == MODULE then return module(second(form), env) end- if f == DEF then return def(second(form), rest(rest(form)), env) end- if f == FN then return execute(compile(form, true), "eval_fn") end+ if f == QUOTE then return second(form) end+ if f == MODULE then return module(second(form), env) end+ if f == DEF then return def(second(form), rest(rest(form)), env) end+ if f == FN then return execute(compile(form, true), "eval_fn") end if f == LET then return execute(compile(form, true), "eval_let") end+ if f == REQUIRE then return req(form) end form = map_eval(form, env) return call(first(form), rest(form))