1
1
mirror of https://github.com/kanaka/mal.git synced 2024-07-14 17:10:30 +03:00

load-file: accept empty file or final comment, return nil

Let `load-file` append a new line in case last line contains a
comment.

Also append `nil` so that the return value is predictible. Remove the
existing explicit `nil` from existing sources.

Adapt documentation and tests.
This commit is contained in:
Nicolas Boulenguez 2019-07-15 23:57:02 +02:00
parent 402fb331d6
commit e6d41de4d5
418 changed files with 411 additions and 446 deletions

View File

@ -266,7 +266,7 @@ procedure Step6_File is
Startup : constant String
:= "(def! not (fn* (a) (if a false true)))"
& "(def! load-file (fn* (f)"
& " (eval (read-string (str ""(do "" (slurp f) "")"")))))";
& " (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))";
Repl : constant Envs.Ptr := Envs.New_Env;
function Eval_Builtin (Args : in Types.T_Array) return Types.T is
begin

View File

@ -346,7 +346,7 @@ procedure Step7_Quote is
Startup : constant String
:= "(def! not (fn* (a) (if a false true)))"
& "(def! load-file (fn* (f)"
& " (eval (read-string (str ""(do "" (slurp f) "")"")))))";
& " (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))";
Repl : constant Envs.Ptr := Envs.New_Env;
function Eval_Builtin (Args : in Types.T_Array) return Types.T is
begin

View File

@ -395,7 +395,7 @@ procedure Step8_Macros is
Startup : constant String
:= "(def! not (fn* (a) (if a false true)))"
& "(def! load-file (fn* (f)"
& " (eval (read-string (str ""(do "" (slurp f) "")"")))))"
& " (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))"
& "(defmacro! cond (fn* (& xs)"
& " (if (> (count xs) 0)"
& " (list 'if (first xs)"

View File

@ -425,7 +425,7 @@ procedure Step9_Try is
Startup : constant String
:= "(def! not (fn* (a) (if a false true)))"
& "(def! load-file (fn* (f)"
& " (eval (read-string (str ""(do "" (slurp f) "")"")))))"
& " (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))"
& "(defmacro! cond (fn* (& xs)"
& " (if (> (count xs) 0)"
& " (list 'if (first xs)"

View File

@ -431,7 +431,7 @@ procedure StepA_Mal is
Startup : constant String
:= "(def! not (fn* (a) (if a false true)))"
& "(def! load-file (fn* (f)"
& " (eval (read-string (str ""(do "" (slurp f) "")"")))))"
& " (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))"
& "(defmacro! cond (fn* (& xs)"
& " (if (> (count xs) 0)"
& " (list 'if (first xs)"

View File

@ -358,7 +358,7 @@ begin
Envs.Set (Repl_Env, "eval", New_Func_Mal_Type ("eval", Do_Eval'Unrestricted_Access));
RE ("(def! not (fn* (a) (if a false true)))");
RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) "")"")))))");
RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))");
-- Command line processing.

View File

@ -449,7 +449,7 @@ begin
Envs.Set (Repl_Env, "eval", New_Func_Mal_Type ("eval", Do_Eval'Unrestricted_Access));
RE ("(def! not (fn* (a) (if a false true)))");
RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) "")"")))))");
RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))");
-- Command line processing.

View File

@ -525,7 +525,7 @@ begin
Envs.Set (Repl_Env, "eval", New_Func_Mal_Type ("eval", Do_Eval'Unrestricted_Access));
RE ("(def! not (fn* (a) (if a false true)))");
RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) "")"")))))");
RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))");
RE ("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw ""odd number of forms to cond"")) (cons 'cond (rest (rest xs)))))))");
-- Command line processing.

View File

@ -578,7 +578,7 @@ begin
Envs.Set (Repl_Env, "eval", New_Func_Mal_Type ("eval", Do_Eval'Unrestricted_Access));
RE ("(def! not (fn* (a) (if a false true)))");
RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) "")"")))))");
RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))");
RE ("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw ""odd number of forms to cond"")) (cons 'cond (rest (rest xs)))))))");
-- Command line processing.

View File

@ -578,7 +578,7 @@ begin
Envs.Set (Repl_Env, "eval", New_Func_Mal_Type ("eval", Do_Eval'Unrestricted_Access));
RE ("(def! not (fn* (a) (if a false true)))");
RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) "")"")))))");
RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))");
RE ("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw ""odd number of forms to cond"")) (cons 'cond (rest (rest xs)))))))");
-- Command line processing.

View File

@ -325,7 +325,7 @@ function main(str, ret, i, idx)
env_set(repl_env, "'eval", "&eval")
rep("(def! not (fn* (a) (if a false true)))")
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))")
idx = types_allocate()
env_set(repl_env, "'*ARGV*", "(" idx)

View File

@ -415,7 +415,7 @@ function main(str, ret, i, idx)
env_set(repl_env, "'eval", "&eval")
rep("(def! not (fn* (a) (if a false true)))")
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))")
idx = types_allocate()
env_set(repl_env, "'*ARGV*", "(" idx)

View File

@ -505,7 +505,7 @@ function main(str, ret, i, idx)
env_set(repl_env, "'eval", "&eval")
rep("(def! not (fn* (a) (if a false true)))")
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))")
rep("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
idx = types_allocate()

View File

@ -567,7 +567,7 @@ function main(str, ret, i, idx)
env_set(repl_env, "'eval", "&eval")
rep("(def! not (fn* (a) (if a false true)))")
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))")
rep("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
idx = types_allocate()

View File

@ -570,7 +570,7 @@ function main(str, ret, i, idx)
rep("(def! *host-language* \"GNU awk\")")
rep("(def! not (fn* (a) (if a false true)))")
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))")
rep("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
idx = types_allocate()

View File

@ -161,7 +161,7 @@ ENV_SET "${REPL_ENV}" "${r}" "${argv}";
# core.mal: defined using the language itself
REP "(def! not (fn* (a) (if a false true)))"
REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"
REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"
# load/run file from command line (then exit)
if [[ "${1}" ]]; then

View File

@ -206,7 +206,7 @@ ENV_SET "${REPL_ENV}" "${r}" "${argv}";
# core.mal: defined using the language itself
REP "(def! not (fn* (a) (if a false true)))"
REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"
REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"
# load/run file from command line (then exit)
if [[ "${1}" ]]; then

View File

@ -248,7 +248,7 @@ ENV_SET "${REPL_ENV}" "${r}" "${argv}";
# core.mal: defined using the language itself
REP "(def! not (fn* (a) (if a false true)))"
REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"
REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"
REP "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))"
# load/run file from command line (then exit)

View File

@ -261,7 +261,7 @@ ENV_SET "${REPL_ENV}" "${r}" "${argv}";
# core.mal: defined using the language itself
REP "(def! not (fn* (a) (if a false true)))"
REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"
REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"
REP "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))"
# load/run file from command line (then exit)

View File

@ -270,7 +270,7 @@ ENV_SET "${REPL_ENV}" "${r}" "${argv}";
# core.mal: defined using the language itself
REP "(def! *host-language* \"bash\")"
REP "(def! not (fn* (a) (if a false true)))"
REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"
REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"
REP "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))"
# load/run file from command line (then exit)

View File

@ -372,7 +372,7 @@ MAIN:
A$="(def! not (fn* (a) (if a false true)))"
GOSUB RE:AY=R:GOSUB RELEASE
A$="(def! load-file (fn* (f) (eval (read-file f))))"
A$="(def! load-file (fn* (f) (do (eval (read-file f)) nil)))"
GOSUB RE:AY=R:GOSUB RELEASE
REM load the args file

View File

@ -462,7 +462,7 @@ MAIN:
A$="(def! not (fn* (a) (if a false true)))"
GOSUB RE:AY=R:GOSUB RELEASE
A$="(def! load-file (fn* (f) (eval (read-file f))))"
A$="(def! load-file (fn* (f) (do (eval (read-file f)) nil)))"
GOSUB RE:AY=R:GOSUB RELEASE
REM load the args file

View File

@ -529,7 +529,7 @@ MAIN:
A$="(def! not (fn* (a) (if a false true)))"
GOSUB RE:AY=R:GOSUB RELEASE
A$="(def! load-file (fn* (f) (eval (read-file f))))"
A$="(def! load-file (fn* (f) (do (eval (read-file f)) nil)))"
GOSUB RE:AY=R:GOSUB RELEASE
A$="(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs)"

View File

@ -562,7 +562,7 @@ MAIN:
A$="(def! not (fn* (a) (if a false true)))"
GOSUB RE:AY=R:GOSUB RELEASE
A$="(def! load-file (fn* (f) (eval (read-file f))))"
A$="(def! load-file (fn* (f) (do (eval (read-file f)) nil)))"
GOSUB RE:AY=R:GOSUB RELEASE
A$="(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs)"

View File

@ -561,7 +561,7 @@ MAIN:
A$="(def! not (fn* (a) (if a false true)))"
GOSUB RE:AY=R:GOSUB RELEASE
A$="(def! load-file (fn* (f) (eval (read-file f))))"
A$="(def! load-file (fn* (f) (do (eval (read-file f)) nil)))"
GOSUB RE:AY=R:GOSUB RELEASE
A$="(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs)"

View File

@ -20,7 +20,7 @@ UNTIL sym$ = ""
REM Initial forms to evaluate
RESTORE +0
DATA (def! not (fn* (a) (if a false true)))
DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))
DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))
DATA ""
REPEAT
READ form$

View File

@ -20,7 +20,7 @@ UNTIL sym$ = ""
REM Initial forms to evaluate
RESTORE +0
DATA (def! not (fn* (a) (if a false true)))
DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))
DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))
DATA ""
REPEAT
READ form$

View File

@ -20,7 +20,7 @@ UNTIL sym$ = ""
REM Initial forms to evaluate
RESTORE +0
DATA (def! not (fn* (a) (if a false true)))
DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))
DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))
DATA (defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw "odd number of forms to cond")) (cons 'cond (rest (rest xs)))))))
DATA ""
REPEAT

View File

@ -20,7 +20,7 @@ UNTIL sym$ = ""
REM Initial forms to evaluate
RESTORE +0
DATA (def! not (fn* (a) (if a false true)))
DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))
DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))
DATA (defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw "odd number of forms to cond")) (cons 'cond (rest (rest xs)))))))
DATA ""
REPEAT

View File

@ -20,7 +20,7 @@ UNTIL sym$ = ""
REM Initial forms to evaluate
RESTORE +0
DATA (def! not (fn* (a) (if a false true)))
DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))
DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))
DATA (defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw "odd number of forms to cond")) (cons 'cond (rest (rest xs)))))))
DATA (def! *host-language* "BBC BASIC V")
DATA ""

View File

@ -210,7 +210,7 @@ void init_repl_env(int argc, char *argv[]) {
// core.mal: defined using the language itself
RE(repl_env, "", "(def! not (fn* (a) (if a false true)))");
RE(repl_env, "",
"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
}
int main(int argc, char *argv[])

View File

@ -247,7 +247,7 @@ void init_repl_env(int argc, char *argv[]) {
// core.mal: defined using the language itself
RE(repl_env, "", "(def! not (fn* (a) (if a false true)))");
RE(repl_env, "",
"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
}
int main(int argc, char *argv[])

View File

@ -289,7 +289,7 @@ void init_repl_env(int argc, char *argv[]) {
// core.mal: defined using the language itself
RE(repl_env, "", "(def! not (fn* (a) (if a false true)))");
RE(repl_env, "",
"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
RE(repl_env, "", "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))");
}

View File

@ -314,7 +314,7 @@ void init_repl_env(int argc, char *argv[]) {
// core.mal: defined using the language itself
RE(repl_env, "", "(def! not (fn* (a) (if a false true)))");
RE(repl_env, "",
"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
RE(repl_env, "", "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))");
}

View File

@ -320,7 +320,7 @@ void init_repl_env(int argc, char *argv[]) {
RE(repl_env, "", "(def! *host-language* \"c\")");
RE(repl_env, "", "(def! not (fn* (a) (if a false true)))");
RE(repl_env, "",
"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
RE(repl_env, "", "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))");
}

View File

@ -308,7 +308,7 @@ fun string rep(string input)
}
rep("(def! not (fn* (a) (if a false true)))");
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
fun void main()
{

View File

@ -363,7 +363,7 @@ fun string rep(string input)
}
rep("(def! not (fn* (a) (if a false true)))");
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
fun void main()
{

View File

@ -434,7 +434,7 @@ fun string rep(string input)
}
rep("(def! not (fn* (a) (if a false true)))");
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
rep("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))");
fun void main()

View File

@ -451,7 +451,7 @@ fun string rep(string input)
}
rep("(def! not (fn* (a) (if a false true)))");
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
rep("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))");
fun void main()

View File

@ -453,7 +453,7 @@ fun string rep(string input)
}
rep("(def! not (fn* (a) (if a false true)))");
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
rep("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))");
fun void main()

View File

@ -94,7 +94,7 @@
;; core.mal: defined using the language itself
(rep "(def! not (fn* [a] (if a false true)))")
(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \")\")))))")
(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))")
;; repl loop
(defn repl-loop []

View File

@ -117,7 +117,7 @@
;; core.mal: defined using the language itself
(rep "(def! not (fn* [a] (if a false true)))")
(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \")\")))))")
(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))")
;; repl loop
(defn repl-loop []

View File

@ -151,7 +151,7 @@
;; core.mal: defined using the language itself
(rep "(def! not (fn* [a] (if a false true)))")
(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \")\")))))")
(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))")
(rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
;; repl loop

View File

@ -168,7 +168,7 @@
;; core.mal: defined using the language itself
(rep "(def! not (fn* [a] (if a false true)))")
(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \")\")))))")
(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))")
(rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
;; repl loop

View File

@ -178,7 +178,7 @@
#?(:clj (rep "(def! *host-language* \"clojure\")")
:cljs (rep "(def! *host-language* \"clojurescript\")"))
(rep "(def! not (fn* [a] (if a false true)))")
(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \")\")))))")
(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))")
(rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
;; repl loop

View File

@ -71,7 +71,7 @@ repl_env.set types._symbol('*ARGV*'), []
# core.mal: defined using the language itself
rep("(def! not (fn* (a) (if a false true)))");
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
if process? && process.argv.length > 2
repl_env.set types._symbol('*ARGV*'), process.argv[3..]

View File

@ -87,7 +87,7 @@ repl_env.set types._symbol('*ARGV*'), []
# core.mal: defined using the language itself
rep("(def! not (fn* (a) (if a false true)))");
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
if process? && process.argv.length > 2
repl_env.set types._symbol('*ARGV*'), process.argv[3..]

View File

@ -105,7 +105,7 @@ repl_env.set types._symbol('*ARGV*'), []
# core.mal: defined using the language itself
rep("(def! not (fn* (a) (if a false true)))");
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
rep("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
if process? && process.argv.length > 2

View File

@ -114,7 +114,7 @@ repl_env.set types._symbol('*ARGV*'), []
# core.mal: defined using the language itself
rep("(def! not (fn* (a) (if a false true)))");
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
rep("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
if process? && process.argv.length > 2

View File

@ -121,7 +121,7 @@ repl_env.set types._symbol('*ARGV*'), []
# core.mal: defined using the language itself
rep("(def! *host-language* \"CoffeeScript\")")
rep("(def! not (fn* (a) (if a false true)))");
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
rep("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
if process? && process.argv.length > 2

View File

@ -135,7 +135,7 @@
(mal-eval ast *repl-env*))))
(rep "(def! not (fn* (a) (if a false true)))")
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))")
(defvar *use-readline-p* nil)

View File

@ -171,7 +171,7 @@
(mal-eval ast *repl-env*))))
(rep "(def! not (fn* (a) (if a false true)))")
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))")
(defvar *use-readline-p* nil)

View File

@ -226,7 +226,7 @@
(mal-eval ast *repl-env*))))
(rep "(def! not (fn* (a) (if a false true)))")
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))")
(rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
(defvar *use-readline-p* nil)

View File

@ -249,7 +249,7 @@
(mal-eval ast *repl-env*))))
(rep "(def! not (fn* (a) (if a false true)))")
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))")
(rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
(defvar *use-readline-p* nil)

View File

@ -256,7 +256,7 @@
(make-mal-string (lisp-implementation-version)))
(rep "(def! not (fn* (a) (if a false true)))")
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))")
(rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
(rep "(def! *host-language* \"common-lisp\")")

View File

@ -177,7 +177,7 @@ malValuePtr APPLY(malValuePtr op, malValueIter argsBegin, malValueIter argsEnd)
static const char* malFunctionTable[] = {
"(def! not (fn* (cond) (if cond false true)))",
"(def! load-file (fn* (filename) \
(eval (read-string (str \"(do \" (slurp filename) \")\")))))",
(eval (read-string (str \"(do \" (slurp filename) \"\nnil)\")))))",
};
static void installFunctions(malEnvPtr env) {

View File

@ -235,7 +235,7 @@ static malValuePtr quasiquote(malValuePtr obj)
static const char* malFunctionTable[] = {
"(def! not (fn* (cond) (if cond false true)))",
"(def! load-file (fn* (filename) \
(eval (read-string (str \"(do \" (slurp filename) \")\")))))",
(eval (read-string (str \"(do \" (slurp filename) \"\nnil)\")))))",
};
static void installFunctions(malEnvPtr env) {

View File

@ -282,7 +282,7 @@ static const char* malFunctionTable[] = {
"(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))",
"(def! not (fn* (cond) (if cond false true)))",
"(def! load-file (fn* (filename) \
(eval (read-string (str \"(do \" (slurp filename) \")\")))))",
(eval (read-string (str \"(do \" (slurp filename) \"\nnil)\")))))",
};
static void installFunctions(malEnvPtr env) {

View File

@ -331,7 +331,7 @@ static const char* malFunctionTable[] = {
"(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))",
"(def! not (fn* (cond) (if cond false true)))",
"(def! load-file (fn* (filename) \
(eval (read-string (str \"(do \" (slurp filename) \")\")))))",
(eval (read-string (str \"(do \" (slurp filename) \"\nnil)\")))))",
};
static void installFunctions(malEnvPtr env) {

View File

@ -332,7 +332,7 @@ static const char* malFunctionTable[] = {
"(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))",
"(def! not (fn* (cond) (if cond false true)))",
"(def! load-file (fn* (filename) \
(eval (read-string (str \"(do \" (slurp filename) \")\")))))",
(eval (read-string (str \"(do \" (slurp filename) \"\nnil)\")))))",
"(def! *host-language* \"C++\")",
};

View File

@ -157,7 +157,7 @@ REPL_ENV = Mal::Env.new nil
Mal::NS.each { |k, v| REPL_ENV.set(k, Mal::Type.new(v)) }
REPL_ENV.set("eval", Mal::Type.new ->(args : Array(Mal::Type)) { Mal.eval(args[0], REPL_ENV) })
Mal.rep "(def! not (fn* (a) (if a false true)))"
Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"
Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"
argv = Mal::List.new
REPL_ENV.set("*ARGV*", Mal::Type.new argv)

View File

@ -183,7 +183,7 @@ REPL_ENV = Mal::Env.new nil
Mal::NS.each { |k, v| REPL_ENV.set(k, Mal::Type.new(v)) }
REPL_ENV.set("eval", Mal::Type.new ->(args : Array(Mal::Type)) { Mal.eval(args[0], REPL_ENV) })
Mal.rep "(def! not (fn* (a) (if a false true)))"
Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"
Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"
argv = Mal::List.new
REPL_ENV.set("*ARGV*", Mal::Type.new argv)

View File

@ -229,7 +229,7 @@ REPL_ENV = Mal::Env.new nil
Mal::NS.each { |k, v| REPL_ENV.set(k, Mal::Type.new(v)) }
REPL_ENV.set("eval", Mal::Type.new ->(args : Array(Mal::Type)) { Mal.eval(args[0], REPL_ENV) })
Mal.rep "(def! not (fn* (a) (if a false true)))"
Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"
Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"
Mal.rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))"
argv = Mal::List.new

View File

@ -246,7 +246,7 @@ REPL_ENV = Mal::Env.new nil
Mal::NS.each { |k, v| REPL_ENV.set(k, Mal::Type.new(v)) }
REPL_ENV.set("eval", Mal::Type.new ->(args : Array(Mal::Type)) { Mal.eval(args[0], REPL_ENV) })
Mal.rep "(def! not (fn* (a) (if a false true)))"
Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"
Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"
Mal.rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))"
argv = Mal::List.new

View File

@ -252,7 +252,7 @@ REPL_ENV = Mal::Env.new nil
Mal::NS.each { |k, v| REPL_ENV.set(k, Mal::Type.new(v)) }
REPL_ENV.set("eval", Mal::Type.new ->(args : Array(Mal::Type)) { Mal.eval(args[0], REPL_ENV) })
Mal.rep "(def! not (fn* (a) (if a false true)))"
Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"
Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"
Mal.rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))"
Mal.rep("(def! *host-language* \"crystal\")")

View File

@ -154,7 +154,7 @@ namespace Mal {
// 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) \")\")))))");
RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
if (args.Length > fileIdx) {
RE("(load-file \"" + args[fileIdx] + "\")");

View File

@ -186,7 +186,7 @@ namespace Mal {
// 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) \")\")))))");
RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
if (args.Length > fileIdx) {
RE("(load-file \"" + args[fileIdx] + "\")");

View File

@ -225,7 +225,7 @@ namespace Mal {
// 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) \")\")))))");
RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
RE("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))");
if (args.Length > fileIdx) {

View File

@ -246,7 +246,7 @@ namespace Mal {
// 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) \")\")))))");
RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
RE("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))");
if (args.Length > fileIdx) {

View File

@ -247,7 +247,7 @@ namespace Mal {
// core.mal: defined using the language itself
RE("(def! *host-language* \"c#\")");
RE("(def! not (fn* (a) (if a false true)))");
RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
RE("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))");
if (args.Length > fileIdx) {

View File

@ -178,7 +178,7 @@ void main(string[] args)
// core.mal: defined using the language itself
re("(def! not (fn* (a) (if a false true)))", repl_env);
re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env);
re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env);
if (args.length > 1)
{

View File

@ -217,7 +217,7 @@ void main(string[] args)
// core.mal: defined using the language itself
re("(def! not (fn* (a) (if a false true)))", repl_env);
re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env);
re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env);
if (args.length > 1)
{

View File

@ -261,7 +261,7 @@ void main(string[] args)
// core.mal: defined using the language itself
re("(def! not (fn* (a) (if a false true)))", repl_env);
re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env);
re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env);
re("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))", repl_env);
if (args.length > 1)

View File

@ -290,7 +290,7 @@ void main(string[] args)
// core.mal: defined using the language itself
re("(def! not (fn* (a) (if a false true)))", repl_env);
re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env);
re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env);
re("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))", repl_env);
if (args.length > 1)

View File

@ -292,7 +292,7 @@ void main(string[] args)
// core.mal: defined using the language itself
re("(def! *host-language* \"" ~ std.compiler.name ~ "\")", repl_env);
re("(def! not (fn* (a) (if a false true)))", repl_env);
re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env);
re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env);
re("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))", repl_env);
if (args.length > 1)

View File

@ -20,7 +20,7 @@ void setupEnv(List<String> argv) {
rep('(def! not (fn* (a) (if a false true)))');
rep("(def! load-file "
"(fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
"(fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
}
MalType READ(String x) => reader.read_str(x);

View File

@ -20,7 +20,7 @@ void setupEnv(List<String> argv) {
rep('(def! not (fn* (a) (if a false true)))');
rep("(def! load-file "
"(fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
"(fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
}
MalType quasiquote(MalType ast) {

View File

@ -19,7 +19,7 @@ void setupEnv(List<String> argv) {
rep('(def! not (fn* (a) (if a false true)))');
rep("(def! load-file "
" (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
" (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
rep("(defmacro! cond "
" (fn* (& xs) (if (> (count xs) 0) "
" (list 'if (first xs) "

View File

@ -19,7 +19,7 @@ void setupEnv(List<String> argv) {
rep('(def! not (fn* (a) (if a false true)))');
rep("(def! load-file "
" (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
" (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
rep("(defmacro! cond "
" (fn* (& xs) (if (> (count xs) 0) "
" (list 'if (first xs) "

View File

@ -21,7 +21,7 @@ void setupEnv(List<String> argv) {
rep('(def! not (fn* (a) (if a false true)))');
rep("(def! load-file "
" (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
" (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
rep("(defmacro! cond "
" (fn* (& xs) (if (> (count xs) 0) "
" (list 'if (first xs) "

View File

@ -117,7 +117,7 @@
(PRINT (EVAL (READ input) repl-env)))
(rep "(def! not (fn* (a) (if a false true)))")
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))")
(defun readln (prompt)
;; C-d throws an error

View File

@ -150,7 +150,7 @@
(PRINT (EVAL (READ input) repl-env)))
(rep "(def! not (fn* (a) (if a false true)))")
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))")
(defun readln (prompt)
;; C-d throws an error

View File

@ -180,7 +180,7 @@
(PRINT (EVAL (READ input) repl-env)))
(rep "(def! not (fn* (a) (if a false true)))")
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))")
(rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
(defun readln (prompt)

View File

@ -196,7 +196,7 @@
(PRINT (EVAL (READ input) repl-env)))
(rep "(def! not (fn* (a) (if a false true)))")
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))")
(rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
(defun readln (prompt)

View File

@ -197,7 +197,7 @@
(PRINT (EVAL (READ input) repl-env)))
(rep "(def! not (fn* (a) (if a false true)))")
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))")
(rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
(defun readln (prompt)

View File

@ -27,7 +27,7 @@ defmodule Mix.Tasks.Step6File do
read_eval_print("""
(def! load-file
(fn* (f)
(eval (read-string (str "(do " (slurp f) ")")))))
(eval (read-string (str "(do " (slurp f) "\nnil)")))))
""", env)
Mal.Env.set(env, "eval", %Function{value: fn [ast] ->

View File

@ -27,7 +27,7 @@ defmodule Mix.Tasks.Step7Quote do
read_eval_print("""
(def! load-file
(fn* (f)
(eval (read-string (str "(do " (slurp f) ")")))))
(eval (read-string (str "(do " (slurp f) "\nnil)")))))
""", env)
Mal.Env.set(env, "eval", %Function{value: fn [ast] ->

View File

@ -27,7 +27,7 @@ defmodule Mix.Tasks.Step8Macros do
read_eval_print("""
(def! load-file
(fn* (f)
(eval (read-string (str "(do " (slurp f) ")")))))
(eval (read-string (str "(do " (slurp f) "\nnil)")))))
""", env)
# cond

View File

@ -27,7 +27,7 @@ defmodule Mix.Tasks.Step9Try do
read_eval_print("""
(def! load-file
(fn* (f)
(eval (read-string (str "(do " (slurp f) ")")))))
(eval (read-string (str "(do " (slurp f) "\nnil)")))))
""", env)
# cond

View File

@ -35,7 +35,7 @@ defmodule Mix.Tasks.StepAMal do
read_eval_print("""
(def! load-file
(fn* (f)
(eval (read-string (str "(do " (slurp f) ")")))))
(eval (read-string (str "(do " (slurp f) "\nnil)")))))
""", env)
# cond

View File

@ -71,7 +71,7 @@ malInit =
, """(def! load-file
(fn* (f)
(eval (read-string
(str "(do " (slurp f) ")")))))"""
(str "(do " (slurp f) "\nnil)")))))"""
]

View File

@ -71,7 +71,7 @@ malInit =
, """(def! load-file
(fn* (f)
(eval (read-string
(str "(do " (slurp f) ")")))))"""
(str "(do " (slurp f) "\nnil)")))))"""
]

View File

@ -71,7 +71,7 @@ malInit =
, """(def! load-file
(fn* (f)
(eval (read-string
(str "(do " (slurp f) ")")))))"""
(str "(do " (slurp f) "\nnil)")))))"""
, """(defmacro! cond
(fn* (& xs)
(if (> (count xs) 0)

View File

@ -71,7 +71,7 @@ malInit =
, """(def! load-file
(fn* (f)
(eval (read-string
(str "(do " (slurp f) ")")))))"""
(str "(do " (slurp f) "\nnil)")))))"""
, """(defmacro! cond
(fn* (& xs)
(if (> (count xs) 0)

View File

@ -72,7 +72,7 @@ malInit =
, """(def! load-file
(fn* (f)
(eval (read-string
(str "(do " (slurp f) ")")))))"""
(str "(do " (slurp f) "\nnil)")))))"""
, """(defmacro! cond
(fn* (& xs)
(if (> (count xs) 0)

View File

@ -19,7 +19,7 @@ init() ->
Env = core:ns(),
% define the load-file and not functions using mal itself
eval(read("(def! not (fn* (a) (if a false true)))"), Env),
eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"), Env),
eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"), Env),
Env.
loop(Env) ->

View File

@ -19,7 +19,7 @@ init() ->
Env = core:ns(),
% define the load-file and not functions using mal itself
eval(read("(def! not (fn* (a) (if a false true)))"), Env),
eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"), Env),
eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"), Env),
Env.
loop(Env) ->

View File

@ -18,7 +18,7 @@ main([]) ->
init() ->
Env = core:ns(),
eval(read("(def! not (fn* (a) (if a false true)))"), Env),
eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"), Env),
eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"), Env),
eval(read("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))"), Env),
Env.

View File

@ -18,7 +18,7 @@ main([]) ->
init() ->
Env = core:ns(),
eval(read("(def! not (fn* (a) (if a false true)))"), Env),
eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"), Env),
eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"), Env),
eval(read("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))"), Env),
Env.

View File

@ -20,7 +20,7 @@ init() ->
Env = core:ns(),
eval(read("(def! *host-language* \"Erlang\")"), Env),
eval(read("(def! not (fn* (a) (if a false true)))"), Env),
eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"), Env),
eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"), Env),
eval(read("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))"), Env),
Env.

Some files were not shown because too many files have changed in this diff Show More