aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-04-01 23:12:33 -0500
committerJoel Martin <github@martintribe.org>2014-04-01 23:12:33 -0500
commit1617910ad342a55762f3ddabb975849d843cff85 (patch)
tree7d5ec5c3865370fa3cf477b772a79a7b9c6dc109
parent7e872ecfc0b00c3675d64b748a5f1e8754c85b7e (diff)
downloadmal-1617910ad342a55762f3ddabb975849d843cff85.tar.gz
mal-1617910ad342a55762f3ddabb975849d843cff85.zip
All: remove slurp-do, use str around slurp instead.
-rwxr-xr-xbash/step6_file.sh11
-rwxr-xr-xbash/step7_quote.sh11
-rwxr-xr-xbash/step8_macros.sh11
-rwxr-xr-xbash/step9_interop.sh11
-rwxr-xr-xbash/stepA_more.sh11
-rw-r--r--c/step6_file.c13
-rw-r--r--c/step7_quote.c13
-rw-r--r--c/step8_macros.c15
-rw-r--r--c/step9_interop.c15
-rw-r--r--c/stepA_more.c13
-rw-r--r--clojure/src/step6_file.clj3
-rw-r--r--clojure/src/step7_quote.clj5
-rw-r--r--clojure/src/step8_macros.clj3
-rw-r--r--clojure/src/step9_interop.clj3
-rw-r--r--clojure/src/stepA_more.clj3
-rw-r--r--docs/TODO13
-rw-r--r--java/src/main/java/mal/step6_file.java8
-rw-r--r--java/src/main/java/mal/step7_quote.java8
-rw-r--r--java/src/main/java/mal/step8_macros.java8
-rw-r--r--java/src/main/java/mal/stepA_more.java9
-rw-r--r--js/step6_file.js5
-rw-r--r--js/step7_quote.js5
-rw-r--r--js/step8_macros.js5
-rw-r--r--js/step9_interop.js5
-rw-r--r--js/stepA_more.js5
-rw-r--r--make/step6_file.mk4
-rw-r--r--make/step7_quote.mk4
-rw-r--r--make/step8_macros.mk4
-rw-r--r--make/step9_interop.mk4
-rw-r--r--make/stepA_more.mk4
-rw-r--r--mal/step1_read_print.mal2
-rw-r--r--mal/step2_eval.mal2
-rw-r--r--mal/step3_env.mal2
-rw-r--r--mal/step4_if_fn_do.mal2
-rw-r--r--mal/step6_file.mal5
-rw-r--r--mal/step7_quote.mal5
-rw-r--r--mal/step8_macros.mal5
-rw-r--r--mal/stepA_more.mal3
-rw-r--r--php/step6_file.php5
-rw-r--r--php/step7_quote.php5
-rw-r--r--php/step8_macros.php5
-rw-r--r--php/step9_interop.php5
-rw-r--r--php/stepA_more.php5
-rw-r--r--python/step6_file.py3
-rw-r--r--python/step7_quote.py3
-rw-r--r--python/step8_macros.py3
-rw-r--r--python/step9_interop.py3
-rw-r--r--python/stepA_more.py3
48 files changed, 87 insertions, 211 deletions
diff --git a/bash/step6_file.sh b/bash/step6_file.sh
index 9656125..1c8fab5 100755
--- a/bash/step6_file.sh
+++ b/bash/step6_file.sh
@@ -150,14 +150,17 @@ read_string () { READ_STR "${ANON["${1}"]}"; }
_fref "read-string" read_string
_eval () { EVAL "${1}" "${REPL_ENV}"; }
_fref "eval" _eval
-slurp () { string "$(cat "${ANON["${1}"]}")"; }
+slurp () {
+ local lines
+ mapfile lines < "${ANON["${1}"]}"
+ local text="${lines[*]}"; text=${text//$'\n' /$'\n'}
+ string "${text}"
+}
_fref "slurp" slurp
-slurp_do () { string "(do $(cat "${ANON["${1}"]}"))"; }
-_fref "slurp-do" slurp_do
# Defined using the language itself
REP "(def! not (fn* (a) (if a false true)))"
-REP "(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))"
+REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"
if [[ "${1}" ]]; then
echo "${@}"
diff --git a/bash/step7_quote.sh b/bash/step7_quote.sh
index 4bb74ba..cecc3b8 100755
--- a/bash/step7_quote.sh
+++ b/bash/step7_quote.sh
@@ -195,14 +195,17 @@ read_string () { READ_STR "${ANON["${1}"]}"; }
_fref "read-string" read_string
_eval () { EVAL "${1}" "${REPL_ENV}"; }
_fref "eval" _eval
-slurp () { string "$(cat "${ANON["${1}"]}")"; }
+slurp () {
+ local lines
+ mapfile lines < "${ANON["${1}"]}"
+ local text="${lines[*]}"; text=${text//$'\n' /$'\n'}
+ string "${text}"
+}
_fref "slurp" slurp
-slurp_do () { string "(do $(cat "${ANON["${1}"]}"))"; }
-_fref "slurp-do" slurp_do
# Defined using the language itself
REP "(def! not (fn* (a) (if a false true)))"
-REP "(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))"
+REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"
if [[ "${1}" ]]; then
echo "${@}"
diff --git a/bash/step8_macros.sh b/bash/step8_macros.sh
index e86a032..a905958 100755
--- a/bash/step8_macros.sh
+++ b/bash/step8_macros.sh
@@ -232,14 +232,17 @@ _eval () {
EVAL "${1}" "${REPL_ENV}"
}
_fref "eval" _eval
-slurp () { string "$(cat "${ANON["${1}"]}")"; }
+slurp () {
+ local lines
+ mapfile lines < "${ANON["${1}"]}"
+ local text="${lines[*]}"; text=${text//$'\n' /$'\n'}
+ string "${text}"
+}
_fref "slurp" slurp
-slurp_do () { string "(do $(cat "${ANON["${1}"]}"))"; }
-_fref "slurp-do" slurp_do
# Defined using the language itself
REP "(def! not (fn* (a) (if a false true)))"
-REP "(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))"
+REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"
if [[ "${1}" ]]; then
echo "${@}"
diff --git a/bash/step9_interop.sh b/bash/step9_interop.sh
index 930aa2e..e1d57f5 100755
--- a/bash/step9_interop.sh
+++ b/bash/step9_interop.sh
@@ -241,14 +241,17 @@ _eval () {
EVAL "${1}" "${REPL_ENV}"
}
_fref "eval" _eval
-slurp () { string "$(cat "${ANON["${1}"]}")"; }
+slurp () {
+ local lines
+ mapfile lines < "${ANON["${1}"]}"
+ local text="${lines[*]}"; text=${text//$'\n' /$'\n'}
+ string "${text}"
+}
_fref "slurp" slurp
-slurp_do () { string "(do $(cat "${ANON["${1}"]}"))"; }
-_fref "slurp-do" slurp_do
# Defined using the language itself
REP "(def! not (fn* (a) (if a false true)))"
-REP "(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))"
+REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"
if [[ "${1}" ]]; then
echo "${@}"
diff --git a/bash/stepA_more.sh b/bash/stepA_more.sh
index 8caa72d..0902b57 100755
--- a/bash/stepA_more.sh
+++ b/bash/stepA_more.sh
@@ -260,16 +260,19 @@ _eval () {
EVAL "${1}" "${REPL_ENV}"
}
_fref "eval" _eval
-slurp () { string "$(cat "${ANON["${1}"]}")"; }
+slurp () {
+ local lines
+ mapfile lines < "${ANON["${1}"]}"
+ local text="${lines[*]}"; text=${text//$'\n' /$'\n'}
+ string "${text}"
+}
_fref "slurp" slurp
-slurp_do () { string "(do $(cat "${ANON["${1}"]}"))"; }
-_fref "slurp-do" slurp_do
# Defined using the language itself
REP "(def! not (fn* (a) (if a false true)))"
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 "(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))))))))"
-REP "(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))"
+REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"
if [[ "${1}" ]]; then
echo "${@}"
diff --git a/c/step6_file.c b/c/step6_file.c
index 875c32c..bfd81fd 100644
--- a/c/step6_file.c
+++ b/c/step6_file.c
@@ -233,20 +233,9 @@ void init_repl_env() {
}
_ref("slurp", slurp, 1);
- MalVal *slurp_do(MalVal *path) {
- assert_type(path, MAL_STRING, "slurp of non-string");
- char *data = slurp_raw(path->val.string),
- *wrapped_data;
- if (!data || mal_error) { return NULL; }
- wrapped_data = g_strdup_printf("(do %s)", data);
- free(data);
- return malval_new_string(wrapped_data);
- }
- _ref("slurp-do", slurp_do, 1);
-
RE(repl_env, "", "(def! not (fn* (a) (if a false true)))");
RE(repl_env, "",
- "(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))");
+ "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
}
int main(int argc, char *argv[])
diff --git a/c/step7_quote.c b/c/step7_quote.c
index 46ac6a9..5e6de17 100644
--- a/c/step7_quote.c
+++ b/c/step7_quote.c
@@ -269,20 +269,9 @@ void init_repl_env() {
}
_ref("slurp", slurp, 1);
- MalVal *slurp_do(MalVal *path) {
- assert_type(path, MAL_STRING, "slurp of non-string");
- char *data = slurp_raw(path->val.string),
- *wrapped_data;
- if (!data || mal_error) { return NULL; }
- wrapped_data = g_strdup_printf("(do %s)", data);
- free(data);
- return malval_new_string(wrapped_data);
- }
- _ref("slurp-do", slurp_do, 1);
-
RE(repl_env, "", "(def! not (fn* (a) (if a false true)))");
RE(repl_env, "",
- "(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))");
+ "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
}
int main(int argc, char *argv[])
diff --git a/c/step8_macros.c b/c/step8_macros.c
index 23afc33..97da0ec 100644
--- a/c/step8_macros.c
+++ b/c/step8_macros.c
@@ -227,7 +227,7 @@ MalVal *EVAL(MalVal *ast, Env *env) {
}
}
}
-
+
// print
char *PRINT(MalVal *exp) {
if (mal_error) {
@@ -308,20 +308,9 @@ void init_repl_env() {
}
_ref("slurp", slurp, 1);
- MalVal *slurp_do(MalVal *path) {
- assert_type(path, MAL_STRING, "slurp of non-string");
- char *data = slurp_raw(path->val.string),
- *wrapped_data;
- if (!data || mal_error) { return NULL; }
- wrapped_data = g_strdup_printf("(do %s)", data);
- free(data);
- return malval_new_string(wrapped_data);
- }
- _ref("slurp-do", slurp_do, 1);
-
RE(repl_env, "", "(def! not (fn* (a) (if a false true)))");
RE(repl_env, "",
- "(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))");
+ "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
}
int main(int argc, char *argv[])
diff --git a/c/step9_interop.c b/c/step9_interop.c
index 2a98dd8..9c25b40 100644
--- a/c/step9_interop.c
+++ b/c/step9_interop.c
@@ -232,7 +232,7 @@ MalVal *EVAL(MalVal *ast, Env *env) {
}
}
}
-
+
// print
char *PRINT(MalVal *exp) {
if (mal_error) {
@@ -313,20 +313,9 @@ void init_repl_env() {
}
_ref("slurp", slurp, 1);
- MalVal *slurp_do(MalVal *path) {
- assert_type(path, MAL_STRING, "slurp of non-string");
- char *data = slurp_raw(path->val.string),
- *wrapped_data;
- if (!data || mal_error) { return NULL; }
- wrapped_data = g_strdup_printf("(do %s)", data);
- free(data);
- return malval_new_string(wrapped_data);
- }
- _ref("slurp-do", slurp_do, 1);
-
RE(repl_env, "", "(def! not (fn* (a) (if a false true)))");
RE(repl_env, "",
- "(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))");
+ "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
}
int main(int argc, char *argv[])
diff --git a/c/stepA_more.c b/c/stepA_more.c
index 037848a..f5a53ca 100644
--- a/c/stepA_more.c
+++ b/c/stepA_more.c
@@ -342,22 +342,11 @@ void init_repl_env() {
}
_ref("slurp", slurp, 1);
- MalVal *slurp_do(MalVal *path) {
- assert_type(path, MAL_STRING, "slurp of non-string");
- char *data = slurp_raw(path->val.string),
- *wrapped_data;
- if (!data || mal_error) { return NULL; }
- wrapped_data = g_strdup_printf("(do %s)", data);
- free(data);
- return malval_new_string(wrapped_data);
- }
- _ref("slurp-do", slurp_do, 1);
-
RE(repl_env, "", "(def! not (fn* (a) (if a false true)))");
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)))))))");
RE(repl_env, "", "(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))))))))");
RE(repl_env, "",
- "(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))");
+ "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
}
int main(int argc, char *argv[])
diff --git a/clojure/src/step6_file.clj b/clojure/src/step6_file.clj
index 80eedef..2eb4e3d 100644
--- a/clojure/src/step6_file.clj
+++ b/clojure/src/step6_file.clj
@@ -90,10 +90,9 @@
(_ref 'read-string reader/read-string)
(_ref 'eval (fn [ast] (EVAL ast repl-env)))
(_ref 'slurp slurp)
-(_ref 'slurp-do (fn [f] (str "(do " (slurp f) ")")))
(rep "(def! not (fn* [a] (if a false true)))")
-(rep "(def! load-file (fn* [f] (eval (read-string (slurp-do f)))))")
+(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \")\")))))")
(defn -main [& args]
(if args
diff --git a/clojure/src/step7_quote.clj b/clojure/src/step7_quote.clj
index 8f190dd..398b7d2 100644
--- a/clojure/src/step7_quote.clj
+++ b/clojure/src/step7_quote.clj
@@ -102,7 +102,7 @@
(def repl-env (types/env))
(defn rep
[strng]
- (PRINT (EVAL (READ strng), repl-env)))
+ (PRINT (EVAL (READ strng) repl-env)))
(defn _ref [k,v] (types/env-set repl-env k v))
@@ -113,10 +113,9 @@
(_ref 'read-string reader/read-string)
(_ref 'eval (fn [ast] (EVAL ast repl-env)))
(_ref 'slurp slurp)
-(_ref 'slurp-do (fn [f] (str "(do " (slurp f) ")")))
(rep "(def! not (fn* [a] (if a false true)))")
-(rep "(def! load-file (fn* [f] (eval (read-string (slurp-do f)))))")
+(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \")\")))))")
(defn -main [& args]
(if args
diff --git a/clojure/src/step8_macros.clj b/clojure/src/step8_macros.clj
index 8b95ba8..6b696e7 100644
--- a/clojure/src/step8_macros.clj
+++ b/clojure/src/step8_macros.clj
@@ -139,10 +139,9 @@
(_ref 'read-string reader/read-string)
(_ref 'eval (fn [ast] (EVAL ast repl-env)))
(_ref 'slurp slurp)
-(_ref 'slurp-do (fn [f] (str "(do " (slurp f) ")")))
(rep "(def! not (fn* [a] (if a false true)))")
-(rep "(def! load-file (fn* [f] (eval (read-string (slurp-do f)))))")
+(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \")\")))))")
(defn -main [& args]
(if args
diff --git a/clojure/src/step9_interop.clj b/clojure/src/step9_interop.clj
index 48ae687..d78aed7 100644
--- a/clojure/src/step9_interop.clj
+++ b/clojure/src/step9_interop.clj
@@ -142,10 +142,9 @@
(_ref 'read-string reader/read-string)
(_ref 'eval (fn [ast] (EVAL ast repl-env)))
(_ref 'slurp slurp)
-(_ref 'slurp-do (fn [f] (str "(do " (slurp f) ")")))
(rep "(def! not (fn* [a] (if a false true)))")
-(rep "(def! load-file (fn* [f] (eval (read-string (slurp-do f)))))")
+(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \")\")))))")
(defn -main [& args]
(if args
diff --git a/clojure/src/stepA_more.clj b/clojure/src/stepA_more.clj
index 19a0c36..d5d80bf 100644
--- a/clojure/src/stepA_more.clj
+++ b/clojure/src/stepA_more.clj
@@ -157,12 +157,11 @@
(_ref 'read-string reader/read-string)
(_ref 'eval (fn [ast] (EVAL ast repl-env)))
(_ref 'slurp slurp)
-(_ref 'slurp-do (fn [f] (str "(do " (slurp f) ")")))
(rep "(def! not (fn* [a] (if a false true)))")
(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 "(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))))))))")
-(rep "(def! load-file (fn* [f] (eval (read-string (slurp-do f)))))")
+(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \")\")))))")
(defn -main [& args]
(if args
diff --git a/docs/TODO b/docs/TODO
index 324484e..07a75dc 100644
--- a/docs/TODO
+++ b/docs/TODO
@@ -6,21 +6,16 @@ All:
- synchronize function/definitions order/names in files
- move Env into separate file (maybe)?
- - more metadata tests
- - more hash_map tests
+ - more metadata, hash_map, interop tests
- hash-map with space in key string (make)
- - more interop tests
- - support metadata on symbol, hash-map, list, vector, function, atom
+ - metadata on collections: list, vector, hash-map, function, atom
- regular expression matching in runtest
-
- Print full exception when test gets EOF from expect
- - Note that bash 4, Java 1.7, php 5.3 required
- - Break out language eval into step0.5
+ - Break out impl eval into step0.5
- unindent tco while loop for step5-A
- - use str instead of slurp-do
- move printing from type to printer
- - fix conj list vs. vector behavior
+ - split types into types and core
---------------------------------------------
diff --git a/java/src/main/java/mal/step6_file.java b/java/src/main/java/mal/step6_file.java
index 95bfd1c..65d9d38 100644
--- a/java/src/main/java/mal/step6_file.java
+++ b/java/src/main/java/mal/step6_file.java
@@ -168,15 +168,9 @@ public class step6_file {
return new MalString(slurp(fname));
}
});
- _ref(repl_env, "slurp-do", new MalFunction() {
- public MalVal apply(MalList args) throws MalThrowable {
- String fname = ((MalString)args.nth(0)).getValue();
- return new MalString("(do " + slurp(fname) + ")");
- }
- });
RE(repl_env, "(def! not (fn* (a) (if a false true)))");
- RE(repl_env, "(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))");
+ RE(repl_env, "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
Integer fileIdx = 0;
if (args.length > 0 && args[0].equals("--raw")) {
diff --git a/java/src/main/java/mal/step7_quote.java b/java/src/main/java/mal/step7_quote.java
index 49f395e..2a09d3e 100644
--- a/java/src/main/java/mal/step7_quote.java
+++ b/java/src/main/java/mal/step7_quote.java
@@ -199,15 +199,9 @@ public class step7_quote {
return new MalString(slurp(fname));
}
});
- _ref(repl_env, "slurp-do", new MalFunction() {
- public MalVal apply(MalList args) throws MalThrowable {
- String fname = ((MalString)args.nth(0)).getValue();
- return new MalString("(do " + slurp(fname) + ")");
- }
- });
RE(repl_env, "(def! not (fn* (a) (if a false true)))");
- RE(repl_env, "(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))");
+ RE(repl_env, "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
Integer fileIdx = 0;
if (args.length > 0 && args[0].equals("--raw")) {
diff --git a/java/src/main/java/mal/step8_macros.java b/java/src/main/java/mal/step8_macros.java
index c632987..47732dd 100644
--- a/java/src/main/java/mal/step8_macros.java
+++ b/java/src/main/java/mal/step8_macros.java
@@ -237,15 +237,9 @@ public class step8_macros {
return new MalString(slurp(fname));
}
});
- _ref(repl_env, "slurp-do", new MalFunction() {
- public MalVal apply(MalList args) throws MalThrowable {
- String fname = ((MalString)args.nth(0)).getValue();
- return new MalString("(do " + slurp(fname) + ")");
- }
- });
RE(repl_env, "(def! not (fn* (a) (if a false true)))");
- RE(repl_env, "(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))");
+ RE(repl_env, "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
Integer fileIdx = 0;
if (args.length > 0 && args[0].equals("--raw")) {
diff --git a/java/src/main/java/mal/stepA_more.java b/java/src/main/java/mal/stepA_more.java
index ff09aff..d3bb161 100644
--- a/java/src/main/java/mal/stepA_more.java
+++ b/java/src/main/java/mal/stepA_more.java
@@ -279,18 +279,11 @@ public class stepA_more {
return new MalString(slurp(fname));
}
});
- _ref(repl_env, "slurp-do", new MalFunction() {
- public MalVal apply(MalList args) throws MalThrowable {
- String fname = ((MalString)args.nth(0)).getValue();
- return new MalString("(do " + slurp(fname) + ")");
- }
- });
RE(repl_env, "(def! not (fn* (a) (if a false true)))");
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)))))))");
RE(repl_env, "(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))))))))");
-
- RE(repl_env, "(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))");
+ RE(repl_env, "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
Integer fileIdx = 0;
if (args.length > 0 && args[0].equals("--raw")) {
diff --git a/js/step6_file.js b/js/step6_file.js
index b9ec187..6a014eb 100644
--- a/js/step6_file.js
+++ b/js/step6_file.js
@@ -97,13 +97,10 @@ _ref('eval', function(ast) { return EVAL(ast, repl_env); });
_ref('slurp', function(f) {
return require('fs').readFileSync(f, 'utf-8');
});
-_ref('slurp-do', function(f) {
- return '(do ' + require('fs').readFileSync(f, 'utf-8') + ')';
-});
// Defined using the language itself
rep("(def! not (fn* (a) (if a false true)))");
-rep("(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))");
+rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
if (typeof process !== 'undefined' && process.argv.length > 2) {
for (var i=2; i < process.argv.length; i++) {
diff --git a/js/step7_quote.js b/js/step7_quote.js
index 832e47b..6d23595 100644
--- a/js/step7_quote.js
+++ b/js/step7_quote.js
@@ -118,13 +118,10 @@ _ref('eval', function(ast) { return EVAL(ast, repl_env); });
_ref('slurp', function(f) {
return require('fs').readFileSync(f, 'utf-8');
});
-_ref('slurp-do', function(f) {
- return '(do ' + require('fs').readFileSync(f, 'utf-8') + ')';
-});
// Defined using the language itself
rep("(def! not (fn* (a) (if a false true)))");
-rep("(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))");
+rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
if (typeof process !== 'undefined' && process.argv.length > 2) {
for (var i=2; i < process.argv.length; i++) {
diff --git a/js/step8_macros.js b/js/step8_macros.js
index 766f750..65d7a87 100644
--- a/js/step8_macros.js
+++ b/js/step8_macros.js
@@ -142,13 +142,10 @@ _ref('eval', function(ast) { return EVAL(ast, repl_env); });
_ref('slurp', function(f) {
return require('fs').readFileSync(f, 'utf-8');
});
-_ref('slurp-do', function(f) {
- return '(do ' + require('fs').readFileSync(f, 'utf-8') + ')';
-});
// Defined using the language itself
rep("(def! not (fn* (a) (if a false true)))");
-rep("(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))");
+rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
if (typeof process !== 'undefined' && process.argv.length > 2) {
for (var i=2; i < process.argv.length; i++) {
diff --git a/js/step9_interop.js b/js/step9_interop.js
index a811c52..bfc01cb 100644
--- a/js/step9_interop.js
+++ b/js/step9_interop.js
@@ -148,13 +148,10 @@ _ref('eval', function(ast) { return EVAL(ast, repl_env); });
_ref('slurp', function(f) {
return require('fs').readFileSync(f, 'utf-8');
});
-_ref('slurp-do', function(f) {
- return '(do ' + require('fs').readFileSync(f, 'utf-8') + ')';
-});
// Defined using the language itself
rep("(def! not (fn* (a) (if a false true)))");
-rep("(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))");
+rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
if (typeof process !== 'undefined' && process.argv.length > 2) {
for (var i=2; i < process.argv.length; i++) {
diff --git a/js/stepA_more.js b/js/stepA_more.js
index fca3744..2778649 100644
--- a/js/stepA_more.js
+++ b/js/stepA_more.js
@@ -160,15 +160,12 @@ _ref('eval', function(ast) { return EVAL(ast, repl_env); });
_ref('slurp', function(f) {
return require('fs').readFileSync(f, 'utf-8');
});
-_ref('slurp-do', function(f) {
- return '(do ' + require('fs').readFileSync(f, 'utf-8') + ')';
-});
// Defined using the language itself
rep("(def! not (fn* (a) (if a false true)))");
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("(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))))))))");
-rep("(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))");
+rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
if (typeof process !== 'undefined' && process.argv.length > 2) {
for (var i=2; i < process.argv.length; i++) {
diff --git a/make/step6_file.mk b/make/step6_file.mk
index da6de04..0c72a9c 100644
--- a/make/step6_file.mk
+++ b/make/step6_file.mk
@@ -110,13 +110,11 @@ $(call _ref,read-string,$(call function,$$(call READ_STR,$$(1))))
$(call _ref,eval,$(call function,$$(call EVAL,$$(1),$$(REPL_ENV))))
_slurp = $(call string,$(call _read_file,$(1)))
-_slurp_do = $(call string,(do $(call _read_file,$(1))))
$(call _ref,slurp,$(call function,$$(call _slurp,$$(call str_decode,$$($$(1)_value)))))
-$(call _ref,slurp-do,$(call function,$$(call _slurp_do,$$(call str_decode,$$($$(1)_value)))))
# Defined in terms of the language itself
$(call do,$(call REP, (def! not (fn* (a) (if a false true))) ))
-$(call do,$(call REP, (def! load-file (fn* (f) (eval (read-string (slurp-do f))))) ))
+$(call do,$(call REP, (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")"))))) ))
# Load and eval any files specified on the command line
$(if $(MAKECMDGOALS),\
diff --git a/make/step7_quote.mk b/make/step7_quote.mk
index a8695da..2a14c11 100644
--- a/make/step7_quote.mk
+++ b/make/step7_quote.mk
@@ -127,13 +127,11 @@ $(call _ref,read-string,$(call function,$$(call READ_STR,$$(1))))
$(call _ref,eval,$(call function,$$(call EVAL,$$(1),$$(REPL_ENV))))
_slurp = $(call string,$(call _read_file,$(1)))
-_slurp_do = $(call string,(do $(call _read_file,$(1))))
$(call _ref,slurp,$(call function,$$(call _slurp,$$(call str_decode,$$($$(1)_value)))))
-$(call _ref,slurp-do,$(call function,$$(call _slurp_do,$$(call str_decode,$$($$(1)_value)))))
# Defined in terms of the language itself
$(call do,$(call REP, (def! not (fn* (a) (if a false true))) ))
-$(call do,$(call REP, (def! load-file (fn* (f) (eval (read-string (slurp-do f))))) ))
+$(call do,$(call REP, (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")"))))) ))
# Load and eval any files specified on the command line
$(if $(MAKECMDGOALS),\
diff --git a/make/step8_macros.mk b/make/step8_macros.mk
index 2b4e33b..910acb0 100644
--- a/make/step8_macros.mk
+++ b/make/step8_macros.mk
@@ -150,13 +150,11 @@ $(call _ref,read-string,$(call function,$$(call READ_STR,$$(1))))
$(call _ref,eval,$(call function,$$(call EVAL,$$(1),$$(REPL_ENV))))
_slurp = $(call string,$(call _read_file,$(1)))
-_slurp_do = $(call string,(do $(call _read_file,$(1))))
$(call _ref,slurp,$(call function,$$(call _slurp,$$(call str_decode,$$($$(1)_value)))))
-$(call _ref,slurp-do,$(call function,$$(call _slurp_do,$$(call str_decode,$$($$(1)_value)))))
# Defined in terms of the language itself
$(call do,$(call REP, (def! not (fn* (a) (if a false true))) ))
-$(call do,$(call REP, (def! load-file (fn* (f) (eval (read-string (slurp-do f))))) ))
+$(call do,$(call REP, (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")"))))) ))
# Load and eval any files specified on the command line
$(if $(MAKECMDGOALS),\
diff --git a/make/step9_interop.mk b/make/step9_interop.mk
index a3d2b5e..6de228d 100644
--- a/make/step9_interop.mk
+++ b/make/step9_interop.mk
@@ -154,13 +154,11 @@ $(call _ref,read-string,$(call function,$$(call READ_STR,$$(1))))
$(call _ref,eval,$(call function,$$(call EVAL,$$(1),$$(REPL_ENV))))
_slurp = $(call string,$(call _read_file,$(1)))
-_slurp_do = $(call string,(do $(call _read_file,$(1))))
$(call _ref,slurp,$(call function,$$(call _slurp,$$(call str_decode,$$($$(1)_value)))))
-$(call _ref,slurp-do,$(call function,$$(call _slurp_do,$$(call str_decode,$$($$(1)_value)))))
# Defined in terms of the language itself
$(call do,$(call REP, (def! not (fn* (a) (if a false true))) ))
-$(call do,$(call REP, (def! load-file (fn* (f) (eval (read-string (slurp-do f))))) ))
+$(call do,$(call REP, (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")"))))) ))
# Load and eval any files specified on the command line
$(if $(MAKECMDGOALS),\
diff --git a/make/stepA_more.mk b/make/stepA_more.mk
index ec32d85..48c0cb2 100644
--- a/make/stepA_more.mk
+++ b/make/stepA_more.mk
@@ -170,15 +170,13 @@ $(call _ref,read-string,$(call function,$$(call READ_STR,$$(1))))
$(call _ref,eval,$(call function,$$(call EVAL,$$(1),$$(REPL_ENV))))
_slurp = $(call string,$(call _read_file,$(1)))
-_slurp_do = $(call string,(do $(call _read_file,$(1))))
$(call _ref,slurp,$(call function,$$(call _slurp,$$(call str_decode,$$($$(1)_value)))))
-$(call _ref,slurp-do,$(call function,$$(call _slurp_do,$$(call str_decode,$$($$(1)_value)))))
# Defined in terms of the language itself
$(call do,$(call REP, (def! not (fn* (a) (if a false true))) ))
$(call do,$(call 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))))))) ))
$(call do,$(call REP, (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)))))))) ))
-$(call do,$(call REP, (def! load-file (fn* (f) (eval (read-string (slurp-do f))))) ))
+$(call do,$(call REP, (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")"))))) ))
# Load and eval any files specified on the command line
$(if $(MAKECMDGOALS),\
diff --git a/mal/step1_read_print.mal b/mal/step1_read_print.mal
index aba1f82..c24fca8 100644
--- a/mal/step1_read_print.mal
+++ b/mal/step1_read_print.mal
@@ -11,7 +11,7 @@
;; repl
(def! rep (fn* [strng]
- (PRINT (EVAL (READ strng), {}))))
+ (PRINT (EVAL (READ strng) {}))))
(def! -main (fn* []
(let* [line (readline "mal-user> ")]
diff --git a/mal/step2_eval.mal b/mal/step2_eval.mal
index 65a5c78..b27ec91 100644
--- a/mal/step2_eval.mal
+++ b/mal/step2_eval.mal
@@ -43,7 +43,7 @@
"*" *
"/" /})
(def! rep (fn* [strng]
- (PRINT (EVAL (READ strng), repl-env))))
+ (PRINT (EVAL (READ strng) repl-env))))
(def! -main (fn* []
(let* [line (readline "mal-user> ")]
diff --git a/mal/step3_env.mal b/mal/step3_env.mal
index 13c1d7f..a4f2c57 100644
--- a/mal/step3_env.mal
+++ b/mal/step3_env.mal
@@ -58,7 +58,7 @@
;; repl
(def! repl-env (new-env))
(def! rep (fn* [strng]
- (PRINT (EVAL (READ strng), repl-env))))
+ (PRINT (EVAL (READ strng) repl-env))))
(def! _ref (fn* [k v] (env-set repl-env k v)))
(_ref "+" +)
diff --git a/mal/step4_if_fn_do.mal b/mal/step4_if_fn_do.mal
index bdefd59..76a3c3a 100644
--- a/mal/step4_if_fn_do.mal
+++ b/mal/step4_if_fn_do.mal
@@ -75,7 +75,7 @@
;; repl
(def! repl-env (new-env))
(def! rep (fn* [strng]
- (PRINT (EVAL (READ strng), repl-env))))
+ (PRINT (EVAL (READ strng) repl-env))))
(def! _ref (fn* [k v] (env-set repl-env k v)))
diff --git a/mal/step6_file.mal b/mal/step6_file.mal
index 34acd67..b5db13b 100644
--- a/mal/step6_file.mal
+++ b/mal/step6_file.mal
@@ -75,7 +75,7 @@
;; repl
(def! repl-env (new-env))
(def! rep (fn* [strng]
- (PRINT (EVAL (READ strng), repl-env))))
+ (PRINT (EVAL (READ strng) repl-env))))
(def! _ref (fn* [k v] (env-set repl-env k v)))
@@ -86,10 +86,9 @@
(_ref 'read-string read-string)
(_ref 'eval (fn* [ast] (EVAL ast repl-env)))
(_ref 'slurp slurp)
-(_ref 'slurp-do slurp-do)
(rep "(def! not (fn* [a] (if a false true)))")
-(rep "(def! load-file (fn* [f] (eval (read-string (slurp-do f)))))")
+(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
(def! -main (fn* []
(let* [line (readline "mal-user> ")]
diff --git a/mal/step7_quote.mal b/mal/step7_quote.mal
index b6e130d..1ea989c 100644
--- a/mal/step7_quote.mal
+++ b/mal/step7_quote.mal
@@ -103,7 +103,7 @@
;; repl
(def! repl-env (new-env))
(def! rep (fn* [strng]
- (PRINT (EVAL (READ strng), repl-env))))
+ (PRINT (EVAL (READ strng) repl-env))))
(def! _ref (fn* [k v] (env-set repl-env k v)))
@@ -114,10 +114,9 @@
(_ref 'read-string read-string)
(_ref 'eval (fn* [ast] (EVAL ast repl-env)))
(_ref 'slurp slurp)
-(_ref 'slurp-do slurp-do)
(rep "(def! not (fn* [a] (if a false true)))")
-(rep "(def! load-file (fn* [f] (eval (read-string (slurp-do f)))))")
+(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
(def! -main (fn* []
(let* [line (readline "mal-user> ")]
diff --git a/mal/step8_macros.mal b/mal/step8_macros.mal
index cb8909e..c07c9b7 100644
--- a/mal/step8_macros.mal
+++ b/mal/step8_macros.mal
@@ -105,7 +105,7 @@
(= 'macroexpand a0)
(let* [a1 (nth ast 1)]
(MACROEXPAND a1 env))
-
+
(= 'do a0)
(let* [el (eval-ast (rest ast) env)]
(nth el (- (count el) 1)))
@@ -146,10 +146,9 @@
(_ref 'read-string read-string)
(_ref 'eval (fn* [ast] (EVAL ast repl-env)))
(_ref 'slurp slurp)
-(_ref 'slurp-do slurp-do)
(rep "(def! not (fn* [a] (if a false true)))")
-(rep "(def! load-file (fn* [f] (eval (read-string (slurp-do f)))))")
+(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
(def! -main (fn* []
(let* [line (readline "mal-user> ")]
diff --git a/mal/stepA_more.mal b/mal/stepA_more.mal
index 5426d59..013c1bc 100644
--- a/mal/stepA_more.mal
+++ b/mal/stepA_more.mal
@@ -158,12 +158,11 @@
(_ref 'read-string read-string)
(_ref 'eval (fn* [ast] (EVAL ast repl-env)))
(_ref 'slurp slurp)
-(_ref 'slurp-do slurp-do)
(rep "(def! not (fn* [a] (if a false true)))")
(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 "(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))))))))")
-(rep "(def! load-file (fn* [f] (eval (read-string (slurp-do f)))))")
+(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
(def! -main (fn* []
(let* [line (readline "mal-user> ")]
diff --git a/php/step6_file.php b/php/step6_file.php
index 8e923e1..37ea3c6 100644
--- a/php/step6_file.php
+++ b/php/step6_file.php
@@ -110,13 +110,10 @@ _ref('eval', function($ast) {
_ref('slurp', function($f) {
return file_get_contents($f);
});
-_ref('slurp-do', function($f) {
- return "(do " . file_get_contents($f) . ")";
-});
// Defined using the language itself
rep("(def! not (fn* (a) (if a false true)))");
-rep("(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))");
+rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
if (count($argv) > 1) {
for ($i=1; $i < count($argv); $i++) {
diff --git a/php/step7_quote.php b/php/step7_quote.php
index 2ccd130..b035be0 100644
--- a/php/step7_quote.php
+++ b/php/step7_quote.php
@@ -133,13 +133,10 @@ _ref('eval', function($ast) {
_ref('slurp', function($f) {
return file_get_contents($f);
});
-_ref('slurp-do', function($f) {
- return "(do " . file_get_contents($f) . ")";
-});
// Defined using the language itself
rep("(def! not (fn* (a) (if a false true)))");
-rep("(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))");
+rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
if (count($argv) > 1) {
for ($i=1; $i < count($argv); $i++) {
diff --git a/php/step8_macros.php b/php/step8_macros.php
index 20e0f6a..28014cd 100644
--- a/php/step8_macros.php
+++ b/php/step8_macros.php
@@ -158,13 +158,10 @@ _ref('eval', function($ast) {
_ref('slurp', function($f) {
return file_get_contents($f);
});
-_ref('slurp-do', function($f) {
- return "(do " . file_get_contents($f) . ")";
-});
// Defined using the language itself
rep("(def! not (fn* (a) (if a false true)))");
-rep("(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))");
+rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
if (count($argv) > 1) {
for ($i=1; $i < count($argv); $i++) {
diff --git a/php/step9_interop.php b/php/step9_interop.php
index fd7c1d7..26e89f0 100644
--- a/php/step9_interop.php
+++ b/php/step9_interop.php
@@ -160,13 +160,10 @@ _ref('eval', function($ast) {
_ref('slurp', function($f) {
return file_get_contents($f);
});
-_ref('slurp-do', function($f) {
- return "(do " . file_get_contents($f) . ")";
-});
// Defined using the language itself
rep("(def! not (fn* (a) (if a false true)))");
-rep("(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))");
+rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
if (count($argv) > 1) {
for ($i=1; $i < count($argv); $i++) {
diff --git a/php/stepA_more.php b/php/stepA_more.php
index cac80ed..dd004cf 100644
--- a/php/stepA_more.php
+++ b/php/stepA_more.php
@@ -179,15 +179,12 @@ _ref('eval', function($ast) {
_ref('slurp', function($f) {
return file_get_contents($f);
});
-_ref('slurp-do', function($f) {
- return "(do " . file_get_contents($f) . ")";
-});
// Defined using the language itself
rep("(def! not (fn* (a) (if a false true)))");
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("(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))))))))");
-rep("(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))");
+rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
if (count($argv) > 1) {
for ($i=1; $i < count($argv); $i++) {
diff --git a/python/step6_file.py b/python/step6_file.py
index b53863a..8a3432d 100644
--- a/python/step6_file.py
+++ b/python/step6_file.py
@@ -88,11 +88,10 @@ for name, val in types_ns.items(): _ref(name, val)
_ref('read-string', read_str)
_ref('eval', lambda ast: EVAL(ast, repl_env))
_ref('slurp', lambda file: open(file).read())
-_ref('slurp-do', lambda file: "(do" + open(file).read() + ")")
# Defined using the language itself
REP("(def! not (fn* (a) (if a false true)))")
-REP("(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))")
+REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
if len(sys.argv) >= 2:
REP('(load-file "' + sys.argv[1] + '")')
diff --git a/python/step7_quote.py b/python/step7_quote.py
index 3054bb0..7acc322 100644
--- a/python/step7_quote.py
+++ b/python/step7_quote.py
@@ -105,11 +105,10 @@ for name, val in types_ns.items(): _ref(name, val)
_ref('read-string', read_str)
_ref('eval', lambda ast: EVAL(ast, repl_env))
_ref('slurp', lambda file: open(file).read())
-_ref('slurp-do', lambda file: "(do" + open(file).read() + ")")
# Defined using the language itself
REP("(def! not (fn* (a) (if a false true)))")
-REP("(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))")
+REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
if len(sys.argv) >= 2:
REP('(load-file "' + sys.argv[1] + '")')
diff --git a/python/step8_macros.py b/python/step8_macros.py
index 616e7d3..e09942c 100644
--- a/python/step8_macros.py
+++ b/python/step8_macros.py
@@ -125,11 +125,10 @@ for name, val in types_ns.items(): _ref(name, val)
_ref('read-string', read_str)
_ref('eval', lambda ast: EVAL(ast, repl_env))
_ref('slurp', lambda file: open(file).read())
-_ref('slurp-do', lambda file: "(do" + open(file).read() + ")")
# Defined using the language itself
REP("(def! not (fn* (a) (if a false true)))")
-REP("(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))")
+REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
if len(sys.argv) >= 2:
REP('(load-file "' + sys.argv[1] + '")')
diff --git a/python/step9_interop.py b/python/step9_interop.py
index 3a20960..b15497f 100644
--- a/python/step9_interop.py
+++ b/python/step9_interop.py
@@ -134,11 +134,10 @@ for name, val in types_ns.items(): _ref(name, val)
_ref('read-string', read_str)
_ref('eval', lambda ast: EVAL(ast, repl_env))
_ref('slurp', lambda file: open(file).read())
-_ref('slurp-do', lambda file: "(do" + open(file).read() + ")")
# Defined using the language itself
REP("(def! not (fn* (a) (if a false true)))")
-REP("(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))")
+REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
if len(sys.argv) >= 2:
REP('(load-file "' + sys.argv[1] + '")')
diff --git a/python/stepA_more.py b/python/stepA_more.py
index c0c5004..1fda4e3 100644
--- a/python/stepA_more.py
+++ b/python/stepA_more.py
@@ -146,13 +146,12 @@ _ref('readline', lambda prompt: mal_readline.readline(prompt))
_ref('read-string', read_str)
_ref('eval', lambda ast: EVAL(ast, repl_env))
_ref('slurp', lambda file: open(file).read())
-_ref('slurp-do', lambda file: "(do" + open(file).read() + ")")
# Defined using the language itself
REP("(def! not (fn* (a) (if a false true)))")
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("(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))))))))")
-REP("(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))")
+REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
if len(sys.argv) >= 2:
REP('(load-file "' + sys.argv[1] + '")')