On Feb 1, 2009, at 2:44 PM, Craig McDaniel wrote:

Anyone have a better method to go from a symbol to a namespace
qualified symbol? I'm using this ugly kludge now:

(symbol (.substring (.toString (resolve sym)) 2))

I'm keeping a map of currently traced functions and the key is the
namespaced-qualified symbol of the function. See git://github.com/ kreg/traceme.git

The reader will (with the help of the compiler) resolve an unqualified symbol if it's prefixed with syntax quote:

        user=> `doc
        clojure.core/doc
        user=> (class `doc)
        clojure.lang.Symbol

I don't know of a way to do this using only Clojure code at runtime except by using the reader. There are ways to do it by calling the compiler directly using Java.

In this case, would it be adequate to use the var itself as the key in your map rather than the qualified symbol?:

        user=> (var doc)
        #'clojure.core/doc
        user=> ({ (var doc) "it's doc"} (var doc))
        "it's doc"
        user=> #'doc
        #'clojure.core/doc
        user=> ({ #'doc "it's doc"} #'doc)
        "it's doc"

--Steve

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to