O'Reilly logo
  • Leandro Gonçalves de Oliveira thinks this is interesting:

3. Create your own protocol, and then extend it using extend-type and extend-protocol.

From

Cover of Clojure for the Brave and True

Note

(defprotocol OG-Stack (og-push [stack object]) (og-pop [stack]) (og-peek [stack]))

; (extend-type clojure.lang.IPersistentVector ; OG-Stack ; (og-push [stack object] (conj stack object)) ; (og-pop [stack] (pop stack)) ; (og-peek [stack] (last stack)))

(extend-protocol OG-Stack clojure.lang.IPersistentVector (og-push [stack object] (conj stack object)) (og-pop [stack] (pop stack)) (og-peek [stack] (last stack)))