On Tue, Oct 7, 2008 at 2:57 PM, Stuart Halloway <[EMAIL PROTECTED]>wrote:
> > This is a tangent from Brian's question about struct inheritance: > While I am not sure that I want struct inheritance, it seems > unnecessarily hard to write the macro for it. Structs are not first > class citizens, in that you cannot reflect against them. I want to ask: > > (defstruct person :fname :lname) > (struct-keys person) ;hypothetical function > -> (:fname, :lname) > > Of course, by poking around a little bit I can get the answer: > > ; reflective goo > (.get (.getDeclaredField (class person) "keys") person) > -> (:fname :lname) > > Two questions: > > (1) Should Clojure provide a function to reflect on a > PersistentStructMap$Def's keys? I think I found an easy way to get the keys of a struct like: (keys (struct person)) > > (2) Philosophical question: Why not make fields like Def.keys public > to begin with? They are they key public contract of the Def class > anyway. With keys public I would be comfortable with just saying > (.keys person) for the scenario of reflecting against structure > definitions. > > Stuart > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---