Skip to content

Instantly share code, notes, and snippets.

@pedroteixeira
Created June 4, 2010 03:37
Show Gist options
  • Save pedroteixeira/424899 to your computer and use it in GitHub Desktop.
Save pedroteixeira/424899 to your computer and use it in GitHub Desktop.
(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