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/stepA_more.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'ruby/stepA_more.rb') diff --git a/ruby/stepA_more.rb b/ruby/stepA_more.rb index 697caa3..101dee3 100644 --- a/ruby/stepA_more.rb +++ b/ruby/stepA_more.rb @@ -153,6 +153,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! *host-language* \"ruby\")"] @@ -162,11 +163,12 @@ 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 +RE["(println (str \"Mal [\" *host-language* \"]\"))"] while line = _readline("user> ") begin puts REP[line] -- cgit v1.2.3