This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-11-07
Channels
#clojure-dev2017-11-07
09:43 $ clj
Clojure 1.8.0
(defmulti foo :bar)
(defmethod foo :qix [quux znoot] (println 'hi))
#'user/foo
user=> #object[clojure.lang.MultiFn 0x205d38da "clojure.lang.MultiFn@205d38da"]
user=> (foo {:bar :qix})
ArityException Wrong number of args (1) passed to: user/eval5/fn--6 clojure.lang.AFn.throwArity (AFn.java:429)
user=>
Reading through some code, I see that defmethod
does amongst other things a call (fn ~@fn-tail)
which gives us a function named, in my example user/eval5/fn--6
user=> (defmulti foo :bar)
(defmethod foo :qix [quux znoot] (println 'hi))
(foo {:bar :qix})#'user/foo
user=> #object[clojure.lang.MultiFn 0x4e928fbf "clojure.lang.MultiFn@4e928fbf"]
user=>
ArityException Wrong number of args (1) passed to: user/eval5/foo--6 clojure.lang.AFn.throwArity (AFn.java:429)
user=>
Another way to get to this would be to let AFn have a specific name (which would default to getClass().getSimpleName()
and have MultiFn set the name of the AFn when addMethod is called.
Clojure 1.8.0
user=> (defmulti foo :bar)
(defmethod foo :qix [quux znoot] (println 'hi))
(foo {:bar :qix})#'user/foo
user=> #object[clojure.lang.MultiFn 0x4e928fbf "clojure.lang.MultiFn@4e928fbf"]
user=>
ArityException Wrong number of args (1) passed to: foo clojure.lang.AFn.throwArity (AFn.java:441)
user=>
Ticket would be fine