Hey Mamun,

Your problem is that your ^{:test true} metadata isn't being applied
to your functions, as you might expect, but rather to the var that is
pointing to the function. You can see this in the following (#' is a
shorthand to get the var rather than the thing it contains).

user=> (meta f1)
nil
user=> (meta #'f1)
{:arglists ([]), :ns #<Namespace user>, :test true, :name f1, :line 1,
:source "(clojure.core/defn ^{:test true} f1 [] (println \"Call f1
fn\"))\n", :file "NO_SOURCE_PATH"}

You can solve this in two ways:

1) Have `f*` contain a list of symbols, then use `resolve` [1] to get
the vars. Then the definition of `f*` becomes `(def f* (list 'f1
'f2))`

2) Have `f*` contain a list of vars

Once you have the vars then you can use `(-> form meta :test)` to
access the value for the :test metadata.

Due to the way vars are implemented, calling `(form)` when `form` is a
var will actually call the function that `form` is pointing to, so the
earlier function call should continue to work.

I hope that helps!

Carlo

[1]: 
http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/resolve

On Tue, Oct 23, 2012 at 1:30 AM, Mamun <mamuni...@gmail.com> wrote:
> Hi All,
>
> I've a application with following structure. Now I would like to access meta
> data of f1 and f2 within process function.
>
> (defn ^{:test true} f1 []
>     (println "call f1 fn"))
>
> (defn ^{:test false} f2 []
>     (println "call f2 fn"))
>
> (def f* (list f1 f2))
>
> (defn process [form]
>   (do
>     //Would like to access meta data of form
>     (println (str "-->" form))))
>
> (map #(process %1) f*)
>
> Does any one have any idea?
>
>
> Regards,
> Mamun
>
> --
> 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

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

Reply via email to