On Friday, March 2, 2012 7:03:10 AM UTC-6, tim.visher wrote: > > I will not in any way claim to know how or why this works. I'm just > starting to use multimethods myself, but I'll give you my set up that > appears to be working at the moment. > > I have a namespace: > > (ns store.store) > > (defmulti serialize method) > > (defmulti slurp method) > > in store.clj > > I have 1 implementation: > > (ns store.file-system > [:use [store.store]] > …) > > (def base "") > > (defmethod serialize :file-system [_ file-name contents] > (fs-utils/write-to contents (str base "/" file-name))) > > (defmethod slurp :file-system [_ file-name] > (clojure.core/slurp (str base "/" file-name))) > > I then use this from another namespace, requiring store.store and > store.store.file-system: > > (ns library > [:require [wallpaper-manager-core.store.file-system :as > store-file-system]] > [:require [wallpaper-manager-core.store.store :as store]]) > > (binding [store-file-system/base (fs/home)] > (def library (ref (read-library) :validator library-validator))) > > (defn serialize-library [library] > (store/serialize :file-system "library.clj" library)) > > And this all seems to work fine for me. Maybe someone else can explain > why it does for me and doesn't for you. Maybe it has something to do > with `use` vs. `require`? > This does indeed work for me. What I was trying to do was avoid was having to do this part:
... [:require [wallpaper-manager-core.store.store :as store]]) As each time I add a defmethod implementation of my defmulti I'd have to add another require. But maybe that isn't such a bad thing so I'll go with this approach. I prefer it over having a "super parent (*)" namespace unless i needed that "super parent" in multiple places. * by "super parent" I mean a namespace that is only used to include the namespaces that contain the defmulti and defmethods 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