-
-
Save cemerick/6676bbfb35f305d05825 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 defrecord+ | |
[name slots & rest] | |
(let [fields (->> slots (partition 2) (map first) vec) | |
defaults (->> slots (partition 2) (map second) vec)] | |
`(do | |
(defrecord ~name | |
~fields | |
~@rest) | |
(defn ~(symbol (str "new-" name)) | |
[] | |
(~(symbol (str name \.)) ~@defaults)) | |
~name))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment