Skip to content

Instantly share code, notes, and snippets.

Created January 20, 2011 09:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/787621 to your computer and use it in GitHub Desktop.
Save anonymous/787621 to your computer and use it in GitHub Desktop.
(defmacro create-object [name props funcs]
(let [m (reduce #(conj %1 [%2 nil]) {} props)
d (str "dispatcher-" name)
]
`(defn ~(symbol d) [msg# & params#]
(cond
~@(map (fn [f]
(symbol (str "(= " msg# (first f) ") (apply " (last f) " (cons m " params# "))"))
) funcs)
)
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment