Possible Duplicate:
Do clojure protocols allow one to have a variadic method the way funcions do (with an ampersand)?
I'm getting this error when running some Clojure code using a protocol:
Exception in thread "main" java.lang.IllegalArgumentException: No single method: add_component of interface: questar.entity.Entity found for function: add-component of protocol: Entity, compiling:(questar/entity.clj:17)
Here's the code in question:
(defprotocol Entity
(add-component [this cname & args])
(update-component [this cname f & args])
(remove-component [this cname])
(get-component [this cname])
(has-component? [this cname]))
(extend-protocol Entity
clojure.lang.IPersistentMap
(add-component [this cname & args]
(assoc entity cname (apply new-component cname args)))
(update-component [this cname f & args]
(let [component (get-component this cname)]
(add-component this cname (apply f component args))))
(remove-component [this cname]
(dissoc this cname))
(get-component [this cname]
(this cname))
(has-component? [this cname]
(contains? this cname))
clojure.lang.IDeref
(add-component [this cname & args]
(alter this (apply add-component cname args)))
(update-component [this cname f & args]
(alter this (apply update-component cname f args)))
(remove-component [this cname]
(alter this remove-component cname))
(get-component [this cname]
(get-component this @cname))
(has-component? [this cname]
(has-component? this @cname)))
I know this can be related to the arity, but everything looks correct to me. Is this because it can't figure out which version of add-component to call?
Thanks!