I'm trying to extend a simple java class toxi.color.ColorList
with this protocol:
(defprotocol countable
(count [this]))
(extend-protocol countable
ColorList
(count [this]
(.size this)))
when i evaluate this code i see these warning
Warning: protocol #'dat00.protocols/countable is overwriting function count
WARNING: count already refers to: #'clojure.core/count in namespace: dat00.protocols, being replaced by: #'dat00.protocols/count
But this works fine:
(count (ColorList.))
=> 0
But if I try this in same file (or namespace)
(count (range 5))
=> IllegalArgumentException No implementation of method: :count of protocol: #'dat00.protocols/countable found for class: clojure.lang.LazySeq clojure.core/-cache-protocol-fn (core_deftype.clj:541)
So my question is:
Am i misunderstanding some detail about protocols?
Thanks!