From a34b02006527d28db5df5c6553be804770b81f79 Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Wed, 9 Apr 2014 23:58:27 -0500 Subject: 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. --- clojure/src/core.clj | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'clojure/src/core.clj') 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] -- cgit v1.2.3