๐Ÿ“Ad hoc hierarchy system

source

Clojure - Multimethods and Hierarchies

Clojure has an ad hoc hierarchy system. You can define a relationship between any two objects using derive function:

(derive ::rect ::shape)
(derive ::square ::rect)

(derive java.util.Map ::collection)

parents, ancestors, descendants, isa? and ยง Multiple dispatch in Clojure work with this hierarchy.

Next

  • This might be the simplest form of nominal subtyping.

Backlinks