Just to be clear make-instance is a macro on struct:
(defmacro make-instance
"Takes a defclassed struct-basis and creates a struct. Initializes
properties to default values."
[aclass & initializers]
(let [class-key (eval (make-pair aclass))
class-sym (symbol (name aclass))
class-inits (get-all-initializers-for-class class-key)
layout (rest (class-key @*layouts*))
layout-map (zipmap (reverse layout) (replicate (count layout)
nil))
rinitializers (vals (merge layout-map class-inits (apply
hash-map initializers)))]
`(struct ~class-sym ~class-key ~...@rinitializers)))
make-instance and struct are equivalent. make-instance just follows the
principle that the programmer should haven't to do anything a computer can
do for you (I'm still a macro noob, let me know if I'm doing anything
particularly nonsensical here).
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---