Skip to content

Commit f0eef11

Browse files
committed
fixed definline, patch from Chouser
1 parent a4142dc commit f0eef11

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/clj/clojure/core.clj

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3031,14 +3031,13 @@
30313031
(defmacro definline
30323032
"Experimental - like defmacro, except defines a named function whose
30333033
body is the expansion, calls to which may be expanded inline as if
3034-
it were a macro. Cannot be used with variadic (&) args."
3034+
it were a macro. Cannot be used with variadic (&) args."
30353035
[name & decl]
3036-
(let [[args expr] (drop-while (comp not vector?) decl)
3037-
inline (eval (list `fn args expr))]
3036+
(let [[pre-args [args expr]] (split-with (comp not vector?) decl)]
30383037
`(do
3039-
(defn ~name ~args ~(apply inline args))
3040-
(let [v# (var ~name)]
3041-
(.setMeta v# (assoc ^v# :inline ~inline))))))
3038+
(defn ~name ~@pre-args ~args ~(apply (eval (list `fn args expr)) args))
3039+
(alter-meta! (var ~name) assoc :inline (fn ~args ~expr))
3040+
(var ~name))))
30423041

30433042
(defn empty
30443043
"Returns an empty collection of the same category as coll, or nil"

0 commit comments

Comments
 (0)