aboutsummaryrefslogtreecommitdiff
path: root/c
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 /c
parent7e872ecfc0b00c3675d64b748a5f1e8754c85b7e (diff)
downloadmal-1617910ad342a55762f3ddabb975849d843cff85.tar.gz
mal-1617910ad342a55762f3ddabb975849d843cff85.zip
All: remove slurp-do, use str around slurp instead.
Diffstat (limited to 'c')
-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
5 files changed, 7 insertions, 62 deletions
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[])