In Clojure, is there a more elegant way of finding the fully qualified name of a function (known to have meta info) than
(def开发者_StackOverflown fully-qualified-name [fn]
(let [fn-meta (meta fn )
fn-ns (ns-name (:ns fn-meta))
]
(str fn-ns "/" (:name fn-meta))))
A run-time solution is required. Read-time and compile-time solutions are welcome.
(resolve 'foo)
returns the Var named "foo", with its fully-qualified name.
how about syntax-quoting ? it does auto-qualification. use ` instead of '
user=> `(inc)
(clojure.core/inc)
user=> `(fn)
(clojure.core/fn)
type
gives a fully qualified name, regardless of meta info.
The output of .toString could get you started:
user=> (.toString map)
"clojure.core$map@11af7bb"
精彩评论