I'm trying to define records based on meta data read in at runtime,
and I'm attempting to write a function that extracts name and attrs
and passes them to defrecord, but I don't understand how to
dynamically create the symbol for the record name.

e.g.

user=> (defrecord (symbol "foo" "bar") [a b])
java.lang.ClassCastException: clojure.lang.PersistentList cannot be
cast to clojure.lang.Symbol (NO_SOURCE_FILE:5)

Attempting to define fields in any way that I can guess at fail.

e.g.

user=> (def fields [(symbol "a")])
#'user/fields
user=> (defrecord foo fields)
IllegalArgumentException Don't know how to create ISeq from:
clojure.lang.Symbol  clojure.lang.RT.seqFrom (RT.java:487)
user=> (defrecord foo (var fields))
user.foo
user=> (user/map->foo {:a 67})       ;; funny
#user.foo{:var nil, :fields nil, :a 67}

Short of generating a string and calling eval on it, is this possible?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to