当前位置: 动力学知识库 > 问答 > 编程问答 >

namespaces - Clojure: fully qualified name of a function

问题描述:

In Clojure, is there a more elegant way of finding the fully qualified name of a function (known to have meta info) than

(defn 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)
"[email protected]"
分享给朋友:
您可能感兴趣的文章:
随机阅读: