Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 619
chris Avatar asked Sep 21 '10 15:09

chris


2 Answers

(resolve 'foo) returns the Var named "foo", with its fully-qualified name.

like image 136
Stuart Sierra Avatar answered Sep 28 '22 03:09

Stuart Sierra


how about syntax-quoting ? it does auto-qualification. use ` instead of '

user=> `(inc)
(clojure.core/inc)
user=> `(fn)
(clojure.core/fn)
like image 24
Belun Avatar answered Sep 28 '22 01:09

Belun