diff options
| author | Joel Martin <github@martintribe.org> | 2014-04-16 23:57:50 -0500 |
|---|---|---|
| committer | Joel Martin <github@martintribe.org> | 2014-04-16 23:57:50 -0500 |
| commit | 8cb5cda46cf3aef847ae3926dc53a5e5f87fe261 (patch) | |
| tree | 13e5b2878f19ee24272ead8a92a9cb84b33ad0e5 /ruby/step7_quote.rb | |
| parent | a05f7822b10ed4cdd61ed8384299a003baf1c1c6 (diff) | |
| download | mal-8cb5cda46cf3aef847ae3926dc53a5e5f87fe261.tar.gz mal-8cb5cda46cf3aef847ae3926dc53a5e5f87fe261.zip | |
All: move some fns to core. Major cleanup.
- Don't import/require core until step4.
- Define cond/or macros from step8
Diffstat (limited to 'ruby/step7_quote.rb')
| -rw-r--r-- | ruby/step7_quote.rb | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/ruby/step7_quote.rb b/ruby/step7_quote.rb index a39b0ce..78ef117 100644 --- a/ruby/step7_quote.rb +++ b/ruby/step7_quote.rb @@ -106,16 +106,12 @@ end repl_env = Env.new RE = lambda {|str| EVAL(READ(str), repl_env) } REP = lambda {|str| PRINT(EVAL(READ(str), repl_env)) } -_ref = lambda {|k,v| repl_env.set(k, v) } -# Import core functions -$core_ns.each &_ref +# core.rb: defined using ruby +$core_ns.each do |k,v| repl_env.set(k,v) end +repl_env.set(:eval, lambda {|ast| EVAL(ast, repl_env)}) -_ref[:"read-string", lambda {|str| read_str str}] -_ref[:eval, lambda {|ast| EVAL(ast, repl_env)}] -_ref[:slurp, lambda {|f| File.read(f) }] - -# Defined using the language itself +# core.mal: defined using the language itself RE["(def! not (fn* (a) (if a false true)))"] RE["(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"] |
