Hi,
Is there an elegant way of expressing multiple-dispatch (with support
for inheritance) with Clojure's multimethod system?

ie. (defmulti get-length :class)
(defmethod get-length :shape []
  (bla bla bla))

get-length can be called by any map who's :class is derived
from :shape.

But what if we want multiple-dispatch?

(defmulti multiply
  (fn [a b] [(:class a) (:class b)]))
(defmethod multiply [:shape :car] [opA opB]
  (bla bla bla))

My intention is that multiply can be called by:
(multiply my-shape my-car)
AND ALSO:
(multiply my-rectangle my-volkswagen)

Thanks for your help
  -Patrick
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to