Hey,

I have this multi-method setup:

(defmulti dsl-walk :Rule)

(defmulti component-constructor :Component)

(defmethod dsl-walk :SymbolPlus [r]
        (let [children (map dsl-walk (:recurrent r))]
                (apply component-constructor (list {:Component (keyword (:symbol
r)) :children children}))))

(defmethod dsl-walk :KeywordAnyPlus [r]
        (apply component-constructor (list {:Component (apply (:resolver r)
(list (:keyword r))) :name (:keyword r) :values (:any-section r)})))

(defmethod dsl-walk :KeywordArgsPlus [r]
        (apply component-constructor (list {:Component (apply (:resolver r)
(list (:keyword r))) :name (:keyword r) :args (:args-section r)})))


For the :KeywordAnyPlus and :KeywordArgsPlus method defs I need to
provide a "resolver" function. My concern is how to pass in this
function without leaking implementation details onto the callers the
multi-method?

For now I've added the function to the data structure that I pass to
the dsl-walk methods using postwalk. I find this too crude.

I've tried using declare to add a namespace-local function and then
have that function assigned by the functions that use dsl-walk but
haven't found a way to assign a value to a declared var from another
namespace.

I can't add a second argument to the dsl-walk methods since dsl-walk
is being called recursively on a data structure.

What's the best approach to pass in a function from a calling
namespace without leaking implementation details?

Thanks

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