diff options
author | Mike Hinchey <hincheymg@gmail.com> | 2009-08-05 04:22:12 -0700 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2009-11-24 08:01:58 -0500 |
commit | 1b4852fdbd5ca8df86e783e417f01c8db226d428 (patch) | |
tree | 1e4bdec94292c88cf928a90aa7a1a726c523a4fd | |
parent | 490e2f499ffdfaecc6e52805ded285f655b3020d (diff) |
give meaningful names to inline expanders, fix #136
Signed-off-by: Rich Hickey <richhickey@gmail.com>
-rw-r--r-- | src/clj/clojure/core.clj | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj index d6fd24f1..823c65f8 100644 --- a/src/clj/clojure/core.clj +++ b/src/clj/clojure/core.clj @@ -225,7 +225,16 @@ fdecl (if (map? (last fdecl)) (butlast fdecl) fdecl) - m (conj {:arglists (list 'quote (sigs fdecl))} m)] + m (conj {:arglists (list 'quote (sigs fdecl))} m) + m (let [inline (:inline m) + ifn (first inline) + iname (second inline)] + ;; same as: (if (and (= 'fn ifn) (not (symbol? iname))) ...) + (if (if (clojure.lang.Util/equiv 'fn ifn) + (if (instance? clojure.lang.Symbol iname) false true)) + ;; inserts the same fn name to the inline fn if it does not have one + (assoc m :inline (cons ifn (cons name (next inline)))) + m))] (list 'def (with-meta name (conj (if (meta name) (meta name) {}) m)) (cons `fn fdecl))))) @@ -3491,7 +3500,7 @@ (let [[pre-args [args expr]] (split-with (comp not vector?) decl)] `(do (defn ~name ~@pre-args ~args ~(apply (eval (list `fn args expr)) args)) - (alter-meta! (var ~name) assoc :inline (fn ~args ~expr)) + (alter-meta! (var ~name) assoc :inline (fn ~name ~args ~expr)) (var ~name)))) (defn empty |