You'd have to not back-quote Region and then eval the reseult:

user=> (def Country {'fields '((int x) (double y {reference
Region}))})
#'user/Country
user=> ((nth (nth (Country 'fields) 1) 2) 'reference)
Region
user=> (eval ((nth (nth (Country 'fields) 1) 2) 'reference) )
{fields ((datatype x) (datatype y))}

If you want the contents of Region in Country and not its symbol:
(def Country `{fields ((int x) (double y {reference ~Region}))})
and look it up with:
((nth (nth (Country 'fields) 1) 2) 'user/reference)
(((nth (nth (Country 'fields) 1) 2) 'user/reference) 'fields)

Or to avoid the qualified names:
user=> (def Country {'fields (list (list 'int 'x) (list 'double 'y
{'reference Region}))})
#'user/Country
user=> ((nth (nth (Country 'fields) 1) 2) 'reference)
{fields ((datatype x) (datatype y))}
user=> (((nth (nth (Country 'fields) 1) 2) 'reference) 'fields)
((datatype x) (datatype y))


On Apr 1, 7:56 am, Mushfaque Chowdhury
<[email protected]> 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?

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

Reply via email to