There is no good way to do this in 1.2 other than using the instance
mechanism that Aaron suggests.  I have had this need myself for
several meta-programming type use cases (building specialized record
serializers, universal record constructors, etc).  We wrap defrecord
in our own macros that generate multimethod implementations at record
construction time.

One possible solution is to use Java reflection to grab the fields
directly.  Clojure generates some in the class, but I think they all
start with an _, so you skip those and probably come up with the
correct fields.  However, I presume the names would be mangled and
you'd need to de-mangle them.

I'm not sure if there are any enhancements in the 1.3 record support
for this feature.



On Aug 29, 11:54 am, Razvan Rotaru <razvan.rot...@gmail.com> wrote:
> Hi,
>
> Assuming I have:
>
> (defrecord myrecord [:a :b :c])
>
> is there a way to get the list of keys from the record definition?
>
> Thanks,
> Razvan

-- 
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