On Fri, Apr 1, 2011 at 10:56 AM, Mushfaque Chowdhury <mushfaque.chowdh...@googlemail.com> wrote: > Hi > > I'm trying to solve a introspection problem of the following type > > (def Region {'fields '((datatype x) (datatype y))}) > > (def Country {'fields '((int x) (double y {reference `Region}))}) > > I'd like to introspect the fields from Country and see {reference > Region} replaced by (reference ((datatype x) (datatype y))) > > I can get as far as seeing this > > ((nth (nth (Country 'fields) 1) 2) 'reference) > which gives > (quote com.test.Common/Region) > > which is sort of close, but how do I now look at it's fields?
First of all, that's not actually a class, it's a var. Second, does it actually need to be quoted a second level? Third, (second '(quote com.test.Common/Region)) will be the symbol com.test.Common/Region, and if you get that symbol into a local named foo, (ns-resolve *ns* foo) ought to yield up a Var object. And (@that-var 'fiels} then ought to cough up '((datatype x) (datatype y)). Indeed: user=> (def Region {'fields '((datatype x) (datatype y))}) #'user/Region user=> (def Country {'fields '((int x) (double y {reference `Region}))}) #'user/Country user=> (@(ns-resolve (find-ns 'user) (nth ((nth (nth (Country 'fields) 1) 2) 'reference) 1)) 'fields) ((datatype x) (datatype y)) -- 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