aboutsummaryrefslogtreecommitdiff
path: root/clojure/src/core.clj
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-04-09 23:58:27 -0500
committerJoel Martin <github@martintribe.org>2014-04-09 23:58:27 -0500
commita34b02006527d28db5df5c6553be804770b81f79 (patch)
tree526fe400e5a8c34b32a3d93439197db09c7f84ad /clojure/src/core.clj
parentedc3b0640f1b773e185550448e2086279f7b1a7f (diff)
downloadmal-a34b02006527d28db5df5c6553be804770b81f79.tar.gz
mal-a34b02006527d28db5df5c6553be804770b81f79.zip
Fix metadata on functions.
- Don't use metadata to store ast, env, params data. - In Clojure, store metadata on the :meta key of the real metadata. This also allows using any datatype as metadata.
Diffstat (limited to 'clojure/src/core.clj')
-rw-r--r--clojure/src/core.clj14
1 files changed, 12 insertions, 2 deletions
diff --git a/clojure/src/core.clj b/clojure/src/core.clj
index 23dfc55..27599c0 100644
--- a/clojure/src/core.clj
+++ b/clojure/src/core.clj
@@ -4,6 +4,16 @@
(defn mal_throw [obj]
(throw (ex-info "mal exception" {:data obj})))
+;; Metadata
+;; - store metadata at :meta key of the real metadata
+(defn mal_with_meta [obj m]
+ (let [new-meta (assoc (meta obj) :meta m)]
+ (with-meta obj new-meta)))
+
+(defn mal_meta [obj]
+ (:meta (meta obj)))
+
+
;; Atoms
(defn atom? [atm]
(= (type atm) clojure.lang.Atom))
@@ -54,8 +64,8 @@
['apply apply]
['map #(doall (map %1 %2))]
- ['with-meta with-meta]
- ['meta meta]
+ ['with-meta mal_with_meta]
+ ['meta mal_meta]
['atom atom]
['atom? atom?]
['deref deref]