Am 07.08.2009 um 20:55 schrieb Andy Chambers:
> Does clojure have an equivalent of either CLOS's `call-next-method' or
> java's super?
You can use get-method.
(derive ::Foo ::Bar)
(derive ::Foo ::Frob)
(defmulti do-something
type)
(defmethod do-something ::Bar
[x]
(do-bar-stuff x))
(defmethod do-something ::Frob
[x]
(frob x))
(defmethod do-something ::Foo
[x]
(let [frobed-x ((get-method do-something ::Frob) x)
bared-x ((get-method do-something ::Bar) x)]
(do-foo-things frobed-x bared-x)))
Note, that the retrieved method, does not need be in
any way related with the hierarchy. Even if ::Foo is not
derived from ::Bar you could retrieve the ::Bar method
and pass the arguments to it.
Hope this helps.
Sincerely
Meikel