Re: get keys from defrecord

2011-08-30 Thread Ken Wesson
On Mon, Aug 29, 2011 at 10:14 PM, Steve Miner wrote: > > On Aug 29, 2011, at 8:20 PM, Alex Miller wrote: > >> I'm not sure if there are any enhancements in the 1.3 record support >> for this feature. > > > In 1.3beta2, the record class has a static method getBasis that will give you > the fields.

Re: get keys from defrecord

2011-08-29 Thread Steve Miner
On Aug 29, 2011, at 8:20 PM, Alex Miller wrote: > I'm not sure if there are any enhancements in the 1.3 record support > for this feature. In 1.3beta2, the record class has a static method getBasis that will give you the fields. I remember Fogus mentioning this on the mailing list. The desig

Re: get keys from defrecord

2011-08-29 Thread Lee Spector
On Aug 29, 2011, at 2:57 PM, Tassilo Horn wrote: > > I guess the problem with that is that you need to have an instance of > the record before you can use `keys'. And to create an instance, at > least you have to know the number of keys. > > However, you can inspect the record's constructor usi

Re: get keys from defrecord

2011-08-29 Thread Alex Miller
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 gener

Re: get keys from defrecord

2011-08-29 Thread Laurent PETIT
Hi, it could help if you can provide more info on what you're trying to achieve 2011/8/29 Razvan Rotaru > 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 be

Re: get keys from defrecord

2011-08-29 Thread Tassilo Horn
Aaron Bedra writes: > user=> (defrecord MyRecord [a b c]) > user.MyRecord > user=> (def rec (user.MyRecord. "one" "two" "three")) > #'user/rec > user=> (keys rec) > (:a :b :c) I guess the problem with that is that you need to have an instance of the record before you can use `keys'. And to crea

Re: get keys from defrecord

2011-08-29 Thread Aaron Bedra
user=> (defrecord MyRecord [a b c]) user.MyRecord user=> (def rec (user.MyRecord. "one" "two" "three")) #'user/rec user=> (keys rec) (:a :b :c) Cheers, Aaron Bedra -- Clojure/core http://clojure.com On 08/29/2011 12:54 PM, Razvan Rotaru wrote: Hi, Assuming I have: (defrecord myrecord [:a :b

get keys from defrecord

2011-08-29 Thread Razvan Rotaru
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 No