Hi, I'm visiting from the Common Lisp world and I'm wondering if Clojure's multimethods support method combination? (Please forgive me if this has already been asked and just direct me to the relevant documentation.)
Here's a contrived example. B derives from A and both have methods defined for foo. user> (derive ::b ::a) user> (defmulti foo identity) user> (defmethod foo ::a [a] (println "It's an a!")) user> (defmethod foo ::b [b] (println "It's a b!")) user> (foo ::a) It's an a! nil user> (foo ::b) It's a b! nil But suppose I want to (foo ::b) to print both "It's a b!" and "It's an a!"? (This is equivalent to a super.foo() call in Java, or method combination in CL.) I don't see any immediately obvious solution, other than literally calling (foo ::a), which is specific to the example and wouldn't work on a less trivial problem (e.g. if I used class instead of identity for the dispatch function, I would actually have to provide an instance of the superclass, which may be inconvenient or impossible). And if I wanted to do something like CL's before/after/around methods, trying to do that could become very difficult. Any assistance would be appreciated. Thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. 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 -~----------~----~----~----~------~----~------~--~---
