Abstractions (Clojure type selection flowchart)

Protocols (clojure.org/protocols)

Define( defprotocol Slicey (slice [at]))
Extends( extend-type String Slicey (slice [at] ...))
Extend null( extend-type nil Slicey (slice [_] nil))
Reify( reify Slicey (slice [at] ...))
Testsatisfies? extends?
Otherextend extend-protocol extenders

Records (clojure.org/datatypes)

Define( defrecord Pair [h t])
Access(:h (Pair. 1 2))1
CreatePair.->Pairmap->Pair
Testrecord?

Types (clojure.org/datatypes)

Define( deftype Pair [h t])
Access(.h (Pair. 1 2))1
CreatePair.->Pair
With methods( deftype Pair [h t]
  Object
  (toString [this] (str "<" h "," t ">")))

Multimethods (clojure.org/multimethods)

Define( defmulti my-mm dispatch-fn)
Method define( defmethod my-mm :dispatch-value [args] ...)
Dispatchget-method methods
Removeremove-method remove-all-methods
Preferprefer-method prefers
Relationderive isa? parents ancestors descendants make-hierarchy