summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2009-01-25 19:31:16 +0000
committerRich Hickey <richhickey@gmail.com>2009-01-25 19:31:16 +0000
commitf0eef1192258f2908a860b151870e04a3a3ab5bc (patch)
treeacdae02b19d2793c86396df055df0bd46d5b04af
parenta4142dc9c2e107528b90bb885ed5e8d92fd3f621 (diff)
fixed definline, patch from Chouser
-rw-r--r--src/clj/clojure/core.clj11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj
index 5c012155..8d3eef21 100644
--- a/src/clj/clojure/core.clj
+++ b/src/clj/clojure/core.clj
@@ -3031,14 +3031,13 @@
(defmacro definline
"Experimental - like defmacro, except defines a named function whose
body is the expansion, calls to which may be expanded inline as if
- it were a macro. Cannot be used with variadic (&) args."
+ it were a macro. Cannot be used with variadic (&) args."
[name & decl]
- (let [[args expr] (drop-while (comp not vector?) decl)
- inline (eval (list `fn args expr))]
+ (let [[pre-args [args expr]] (split-with (comp not vector?) decl)]
`(do
- (defn ~name ~args ~(apply inline args))
- (let [v# (var ~name)]
- (.setMeta v# (assoc ^v# :inline ~inline))))))
+ (defn ~name ~@pre-args ~args ~(apply (eval (list `fn args expr)) args))
+ (alter-meta! (var ~name) assoc :inline (fn ~args ~expr))
+ (var ~name))))
(defn empty
"Returns an empty collection of the same category as coll, or nil"