Skip to content

Instantly share code, notes, and snippets.

@raek raek/my-macro.clj forked from anonymous/my-macro.clj
Created Jan 20, 2011

Embed
What would you like to do?
(defmacro create-object [name props funcs]
(let [m (reduce #(conj %1 [%2 nil]) {} props)
d (symbol (str "dispatcher-" name))
msg-sym (gensym "msg")
params-sym (gensym "params")]
`(defn ~d [~msg-sym &~params-sym]
(cond
~@(for [f funcs]
[(= ~msg-sym ~(first f))
(apply ~(second f) ~m ~params-sym)])))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.