On 26.03.2009, at 14:59, Rich Hickey wrote: > Plus the inability to dispatch on other than class or eql, the > inability to superimpose another taxonomy without redefining the > class, the inability to have multiple independent taxonomies...
The ability to have multiple taxonomies is indeed very useful in my (limited) experience. > One is left-to-right argument order precedence, which roughly > translates to vector precedence in Clojure (although the mapping to a > vector need not follow arg order). I am not sure I'd want such a precedence. If I dispatch on several arguments, their role is sometimes symmetric, sometimes not, and where it is not, it is not necessarily the first argument that takes precedence. However, what I wished I had on some occasions is a way to specify a sequence of dispatching values as a result of the dispatch function. For example, in a two-argument dispatch, I'd like to be able to write something like (defmulti foo (fn [x y] (let [tx (type x) ty (type y)] (list [tx ty] (cond (isa? tx ty) ty (isa? ty tx) tx :else #{tx ty}))) with the result of calling a method for [tx ty] if available and one of tx/ty/#{tx ty} otherwise. Without such an option, I sometimes have to write several methods with an identical implementation but different dispatch signatures. One way to make this and other generalizations possible would be to have access to the multimethod's implementation list (and perhaps preference order) in the dispatch function. > What I like about preference declarations is that you are > acknowledging a definite ambiguity in a pure derivation hierarchy > rather than poisoning the notion of hierarchy with directionality. What I like about them is that an ambiguity often points to a design problem that should better be fixed than circumvented. > That said, perhaps the preference specifications at the method level > aren't as reusable/convenient as preferences declared at another level > or somewhere else. How about a preference function on each multimethod, along with the dispatch function? One could then easily use one such function for several multimethods. But what I suggested above (access to the dispatch signatures and preferences in the dispatch function) should be even more general. Konrad. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---