Hierarchies in Clojure are used to make child-parent relationships between classes, keywords, and symbols. These relationships can be used to determine which code body to evaluate for a
defmulti function. This chapter will go over the capabilities of hierarchies, and then introduce examples of how to use hierarchies with
Hierarchies are global by default but, for the following example, the
local-h symbol will hold the relationships. Because the
make-hierarchy form returns a persistent array-map, the hierarchy is wrapped inside an atom so that the
swap! form can apply and maintain changes to the hierarchy:
user> (def local-h (atom (make-hierarchy))) #'user/local-h
In the following example, the ...