Created
January 20, 2011 09:19
-
-
Save anonymous/787621 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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