It does work.

As far as I can tell, the namespace with defmethod must require the
namespace with defmulti and also the namespace with defmethod must be
required from some other namespace that is being executed.

Eg:

*foo.clj:*
(ns foo)
(defmulti mmtest identity)
(defmethod mmtest :default [_] (println "default"))

*bar.clj:*
(ns bar
  (:require [foo]))
(defmethod mmtest :bar [_] (println "in bar"))

*core.clj:*
(ns core
  (:require [foo :refer [mmtest]] ; The mm we want to call
               [bar])) ; include the :bar impl

(println "Testing")
(mmtest :bar) ; Prints "in bar"


If you don't require bar from core, it will print default instead.

Note, in this example I require foo and bar from core and use mmtest in
core too - you don't need to require bar from the same namespace that you
use in from like I did here. You just need to make sure that the (defmethod
...) call gets executed before you call mmtest.



On 10 July 2014 19:09, Elric Erkose <elric.erk...@gmail.com> wrote:

> This sounds interesting. I tried to define a multimethod in one file and a
> method in another file. I had no success.
>
>>   --
> 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
> Note that posts from new members are moderated - please be patient with
> your first post.
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to