Расширения

(defrecord Point [x y])

;; a protocol may be attached to a type whose source you do not own,
;; and that is Clojure's "extension method"
(defprotocol Distance
  (distance-to [this other]))

(extend-protocol Distance
  Point
  (distance-to [p other]
    (Math/hypot (- (:x p) (:x other))
                (- (:y p) (:y other)))))

(def distance (distance-to (->Point 1.0 2.0) (->Point 2.0 3.0)))
;; distance is 1.4142
(println "distance is" (format "%.4f" distance))

;; the very same trick works on a java class, String among them
(extend-protocol Distance
  String
  (distance-to [s other] (abs (- (count s) (count other)))))

(println "distance is" (distance-to "abcde" "ab"))