Make defhelper work.

This commit is contained in:
Richard Newman 2016-07-11 11:00:49 -07:00
parent ec03b7c06f
commit f9546af9ca

View file

@ -18,18 +18,20 @@
(let [kw (keyword (name helper))] (let [kw (keyword (name helper))]
`(do `(do
(defmethod build-clause ~kw ~(into ['_] arglist) ~@more) (defmethod build-clause ~kw ~(into ['_] arglist) ~@more)
(doto (defn ~helper [& args#] (defn ~helper [& args#]
(let [[m# args#] (if (plain-map? (first args#)) (let [[m# args#] (if (plain-map? (first args#))
[(first args#) (rest args#)] [(first args#) (rest args#)]
[{} args#])] [{} args#])]
(build-clause ~kw m# args#))) (build-clause ~kw m# args#)))
;; maintain the original arglist instead of getting ;; maintain the original arglist instead of getting
;; ([& args__6880__auto__]) ;; ([& args__6880__auto__])
(alter-meta! (alter-meta!
(var ~helper)
assoc assoc
:arglists :arglists
'(~(into [] (rest arglist)) '(~(into [] (rest arglist))
~(into [(first arglist)] (rest arglist))))))))) ~(into [(first arglist)] (rest arglist))))))))
(defn collify [x] (defn collify [x]
(if (coll? x) x [x])) (if (coll? x) x [x]))