From 86b689f3d7111a9fa13da389a30f3dfdf877d1a4 Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Sat, 19 Apr 2014 13:04:09 -0500 Subject: All: *ARGV* and *host-language*. Misc syncing/fixes. --- ruby/step8_macros.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'ruby/step8_macros.rb') diff --git a/ruby/step8_macros.rb b/ruby/step8_macros.rb index dd02c4f..3c99cce 100644 --- a/ruby/step8_macros.rb +++ b/ruby/step8_macros.rb @@ -136,6 +136,7 @@ REP = lambda {|str| PRINT(EVAL(READ(str), repl_env)) } # 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)}) +repl_env.set(:"*ARGV*", List.new(ARGV.slice(1,ARGV.length) || [])) # core.mal: defined using the language itself RE["(def! not (fn* (a) (if a false true)))"] @@ -144,11 +145,11 @@ RE["(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> RE["(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))"] if ARGV.size > 0 - ARGV.each {|f| - RE["(load-file \"" + f + "\")"] - } + RE["(load-file \"" + ARGV[0] + "\")"] exit 0 end + +# repl loop while line = _readline("user> ") begin puts REP[line] -- cgit v1.2.3