Hi,

I recently was writing a macro that creates requires creating a worker
fn, and the wrapping a worker fn with an adapter fn.  The adapter fn
is what I intend to have called.  To give you an idea what's going on:

user=>(doc my-fn)
"This calls my-fn* to do some work, after my-fn calls a multimethod to
adapt the input."

user=>(doc my-fn*)
"This does the work"

In order for it to work it needs access to the symbols in the binding
vars.  The problem is that the bindings might be variadic, so I need
to remove the & symbol.  Here's the macro.

(defmacro defmod [sym docstring binding body]
  (let [base-sym (symbol (str sym "*"))
        base-doc (str "This is the base function designed to work on a
string. \n\n" docstring)
        versatile-doc (str "multifn - This is the wrapped multimethod
designed to work on strings, keywords or symbols. \n\n  " docstring)]
    `(do
      (defn ~base-sym ~base-doc ~binding ~body)
      (defn ~sym ~versatile-doc ~binding
        (apply mod ~base-sym ~@(remove #{'&} binding))))))

Is the ~@(remove #{'&} binding) the proper s-exp to do this?

Thanks!
Sean

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