aboutsummaryrefslogtreecommitdiff
path: root/clojure/src
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-10-09 23:48:47 -0500
committerJoel Martin <github@martintribe.org>2015-01-06 21:57:24 -0600
commit01c9731649a7ed97fad0bdeac9cb75b7323c0ad6 (patch)
treed6d00e574c489b206ddf78adc12c3d535bab7440 /clojure/src
parent1771ab50b87c745181e4e30f94b63e3f23d33dac (diff)
downloadmal-01c9731649a7ed97fad0bdeac9cb75b7323c0ad6.tar.gz
mal-01c9731649a7ed97fad0bdeac9cb75b7323c0ad6.zip
All: swap step9,A. Fixes for bash, C, perl.
step9_interop -> stepA_interop stepA_more -> step9_try C: fix glib headers bash: behavior change of declare -A and pattern replacement. perl: squelch new 5.18 warnings related to switch/given statement. Also, include some in-progress interop related files.
Diffstat (limited to 'clojure/src')
-rw-r--r--clojure/src/step9_try.clj (renamed from clojure/src/step9_interop.clj)24
-rw-r--r--clojure/src/stepA_interop.clj (renamed from clojure/src/stepA_more.clj)2
2 files changed, 20 insertions, 6 deletions
diff --git a/clojure/src/step9_interop.clj b/clojure/src/step9_try.clj
index c4d67e5..4990d75 100644
--- a/clojure/src/step9_interop.clj
+++ b/clojure/src/step9_try.clj
@@ -1,4 +1,4 @@
-(ns step9-interop
+(ns step9-try
(:refer-clojure :exclude [macroexpand])
(:require [clojure.repl]
[readline]
@@ -94,9 +94,20 @@
'macroexpand
(macroexpand a1 env)
- 'clj*
- (eval (reader/read-string a1))
-
+ 'try*
+ (if (= 'catch* (nth a2 0))
+ (try
+ (EVAL a1 env)
+ (catch clojure.lang.ExceptionInfo ei
+ (EVAL (nth a2 2) (env/env env
+ [(nth a2 1)]
+ [(:data (ex-data ei))])))
+ (catch Throwable t
+ (EVAL (nth a2 2) (env/env env
+ [(nth a2 1)]
+ [(.getMessage t)]))))
+ (EVAL a1 env))
+
'do
(do (eval-ast (->> ast (drop-last) (drop 1)) env)
(recur (last ast) env))
@@ -141,6 +152,7 @@
(env/env-set repl-env '*ARGV* ())
;; core.mal: defined using the language itself
+(rep "(def! *host-language* \"clojure\")")
(rep "(def! not (fn* [a] (if a false true)))")
(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \")\")))))")
(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)))))))")
@@ -161,4 +173,6 @@
(env/env-set repl-env '*ARGV* (rest args))
(if args
(rep (str "(load-file \"" (first args) "\")"))
- (repl-loop)))
+ (do
+ (rep "(println (str \"Mal [\" *host-language* \"]\"))")
+ (repl-loop))))
diff --git a/clojure/src/stepA_more.clj b/clojure/src/stepA_interop.clj
index fc7451f..6ed9964 100644
--- a/clojure/src/stepA_more.clj
+++ b/clojure/src/stepA_interop.clj
@@ -1,4 +1,4 @@
-(ns stepA-more
+(ns stepA-interop
(:refer-clojure :exclude [macroexpand])
(:require [clojure.repl]
[readline]