The field names and order in the constructor will always match the
values specified in deftype (excepting certain character issues, such
as turning a dash into an underscore).
Introspecting is easy enough:
user=> (deftype foo [bar baz])
user.foo
user=> (map #(.getName %) (.getDeclaredFields foo))
("bar" "baz")
Though defrecord emits quite a few more fields beyond what was
specified.
On Jun 7, 3:55 pm, Chris Kent <[email protected]> wrote:
> Hi
>
> Is there a way to introspect types defined with deftype and
> defrecord? I'd just like to know the field names and their order in
> the constructor. Java reflection works fine but requires some
> fiddling around to filter the static fields and __meta and __extmap.
> It feels like something that someone has probably aready done.
>
> Also, is it safe to rely on the order the fields are returned from the
> class? They are in the same order as in defrecord and the constructor
> but I'm not sure if this by design or an implementation detail of my
> particular JVM.
>
> Thanks
> Chris
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
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