Created
June 4, 2010 03:37
-
-
Save pedroteixeira/424899 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 record | |
"Dynamic factory for defrecords." | |
([name] `(record ~name {}) ) | |
([name vals-map] | |
`(let [con# (first (.getDeclaredConstructors ~name)) | |
num# (alength (.getParameterTypes con#))] | |
(merge (.newInstance con# (make-array Object num#)) ~vals-map)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment