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