1
1
mirror of https://github.com/kanaka/mal.git synced 2024-11-10 02:45:44 +03:00

factor: Set *ARGV* and run command-line script correctly in step6-stepA

This commit is contained in:
Dov Murik 2016-05-12 08:51:19 -04:00
parent 8a16f95375
commit b85c07fd07
5 changed files with 33 additions and 9 deletions

View File

@ -89,9 +89,15 @@ M: callable apply call( x -- y ) f ;
] keep
] loop ;
: main ( -- )
command-line get
[ REPL ]
[ first "(load-file \"" "\")" surround REP drop ]
if-empty ;
f ns clone
[ first repl-env get EVAL ] "eval" pick set-at
command-line get "*ARGV*" pick set-at
command-line get dup empty? [ rest ] unless "*ARGV*" pick set-at
<malenv> repl-env set-global
"
@ -99,4 +105,4 @@ command-line get "*ARGV*" pick set-at
(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))
" string-lines harvest [ REP drop ] each
MAIN: REPL
MAIN: main

View File

@ -104,9 +104,15 @@ M: callable apply call( x -- y ) f ;
] keep
] loop ;
: main ( -- )
command-line get
[ REPL ]
[ first "(load-file \"" "\")" surround REP drop ]
if-empty ;
f ns clone
[ first repl-env get EVAL ] "eval" pick set-at
command-line get "*ARGV*" pick set-at
command-line get dup empty? [ rest ] unless "*ARGV*" pick set-at
<malenv> repl-env set-global
"
@ -114,4 +120,4 @@ command-line get "*ARGV*" pick set-at
(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))
" string-lines harvest [ REP drop ] each
MAIN: REPL
MAIN: main

View File

@ -122,9 +122,15 @@ M: callable apply call( x -- y ) f ;
] keep
] loop ;
: main ( -- )
command-line get
[ REPL ]
[ first "(load-file \"" "\")" surround REP drop ]
if-empty ;
f ns clone
[ first repl-env get EVAL ] "eval" pick set-at
command-line get "*ARGV*" pick set-at
command-line get dup empty? [ rest ] unless "*ARGV*" pick set-at
<malenv> repl-env set-global
"
@ -134,4 +140,4 @@ command-line get "*ARGV*" pick set-at
(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))))))))
" string-lines harvest [ REP drop ] each
MAIN: REPL
MAIN: main

View File

@ -130,9 +130,15 @@ M: callable apply call( x -- y ) f ;
] keep
] loop ;
: main ( -- )
command-line get
[ REPL ]
[ first "(load-file \"" "\")" surround REP drop ]
if-empty ;
f ns clone
[ first repl-env get EVAL ] "eval" pick set-at
command-line get "*ARGV*" pick set-at
command-line get dup empty? [ rest ] unless "*ARGV*" pick set-at
<malenv> repl-env set-global
"
@ -142,4 +148,4 @@ command-line get "*ARGV*" pick set-at
(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))))))))
" string-lines harvest [ REP drop ] each
MAIN: REPL
MAIN: main

View File

@ -134,7 +134,7 @@ M: callable apply call( x -- y ) f ;
: main ( -- )
command-line get
[ REPL ]
[ first "(load-file \"" "\")" surround REP print flush ]
[ first "(load-file \"" "\")" surround REP drop ]
if-empty ;
f ns clone