I attempted to do something like this:

(ns parent)
(defmulti my-method (fn [x] (:method x))

(ns child1)
(defmethod my-method :zzz
  ...)

(ns child2)
(defmethod my-method :aaa
  ...)

However the problem is the children need to use the parent namespace in 
order to have the method definition and the code that uses all of this 
needs to use all the namespaces too. This creates a circular reference and 
compilation fails.

I can solve this by doing this:

(ns super-parent
 (:use parent
         child1
         child2))

The children can still do (:use parent) and then I can "use super-parent" 
in my other code but it seems silly to have to create this super-parent.

1) Is it a bad idea to try to put the defmulti and defmethods into separate 
namespaces?
2) Is there another way to do this which would allow separate namespaces 
without requiring super-parent?

The whole reason I'm trying to spilt things up is to make testing easier.

Thanks,
Cymen

-- 
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

Reply via email to