I was playing around with protocols at the REPL and encountered the following:
(defprotocol IGreeter
(greet [this]))
(deftype MyGreeter []
IGreeter
(greet [_] "hi from MyGreeter"))
(extends? IGreeter MyGreeter)
;=> true
;; I expected to see MyGreeter listed here, but result is nil
(extenders IGreeter)
;=> nil
Now extend the protocol to a few types.
(extend-protocol IGreeter
String
(greet [this] "hi-string")
clojure.lang.Symbol
(greet [this] 'hi-sym) ; ' help syntax highlighter
clojure.lang.Keyword
(greet [this] :hi-kw))
(extenders IGreeter)
;=> (java.lang.String clojure.lang.Symbol clojure.lang.Keyword)
String, Symbol and Keyword show up as extenders of IGreeter. MyGreeter does not. This was especially surprising since (extends? IGreeter MyGreeter) returns true. Am I misunderstanding something or could this be a bug? Thank you!