Dear Clojurians, This patch allows multimethods to use different hierarchies, than the global hierarchy for use with isa?. Currently only the global hierarchy is possible.
The patch extends the MultiFn class to accept also a Var pointing to a hierarchy. The rationale is, that otherwise the multimethod cannot be extended with derivation after it's definition. Hence it cannot receive the hierarchy directly. To promote that every hierarchy must be a Var, derive and underive are modified to act on vars instead of the hierarchies directly. Furthermore the convenience macros defhierarchy and defhierarchy- are provided, which define new hierarchies with optional docstring support and automatic initialisation with make-hierarchy. This is listed as a "hot" item in the Todo list and is connected to http://code.google.com/p/clojure/issues/detail?id=8. In fact the patch there is needed as a prerequisite. Example of usage: (defhierarchy our-hierarchy "This is a dedicated hierarchy for our own purposes!") ; Note: here we need the Var, hence the #'. ; Should this be handled via a macro? (derive #'our-hierarchy :xxx :yyy) (defmulti foo identity :hierarchy our-hierarchy) (defmethod foo :yyy [x] (println "We are in" :yyy "but got" x)) Comments and feedback appreciated. Sincerely Meikel
issue-8a.diff
Description: Binary data
smime.p7s
Description: S/MIME cryptographic signature