Direct copy-paste from my repl:
user=> (defn ^{:test true} f1 []
#_=> (println "call f1 fn"))
#'user/f1
user=>
user=> (defn ^{:test false} f2 []
#_=> (println "call f2 fn"))
#'user/f2
user=> (:test (meta (var f1)))
true
user=> (:test (meta (var f2)))
false
user=> (println (:test (meta (var f2))))
false
nil
...this proves that it works as I described previously...probably your
f1 var is namespaced so unless you're in that namespace or you 're
'use'ing that namespace you need to qualify the var...I suggest you try
again...
Jim
On 22/10/12 22:24, Mamun wrote:
Hi Jim
Thank for your ans. But this does not work. When I run code I got
"Unable to resolve var" error. Please find in bellow:
CompilerException java.lang.RuntimeException: Unable to resolve var:
form in this context, compiling:(NO_SOURCE_PATH:4)
Source code-
(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
(form) ; it will call f1, f2...
;I need to access meta data of f1, f2......
*;(println (:test (meta (var form)))) ;Error*
(println (str "-->" form))))
(map #(process %1) f*)
Regards,
Mamun
On Monday, October 22, 2012 5:45:21 PM UTC+2, Jim foo.bar wrote:
well not quite!
you need (-> form
var
meta
:test)
or the same thing written differently (:test (meta (var form)))
Hope that helps,
Jim
ps: basically the meta-data sit with the var not the function
On 22/10/12 16:33, Jim foo.bar wrote:
If I've understood correctly all you need is (meta form)...
Jim
On 22/10/12 15:30, Mamun 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 clo...@googlegroups.com
<javascript:>
Note that posts from new members are moderated - please be
patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com <javascript:>
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
<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
--
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