How to get the namespace for an unqualified symbol?

2012-11-12 Thread johnstok
I was looking at combining the namespace and resolve functions: user= (def x 5) #'user/x user= (resolve 'x) #'user/x user= (namespace 'user/x) user user= (namespace 'x) nil user= (namespace (resolve 'x)) ClassCastException clojure.lang.Var cannot be cast to clojure.lang.Named

Re: How to get the namespace for an unqualified symbol?

2012-11-12 Thread Tassilo Horn
Ambrose Bonnaire-Sergeant abonnaireserge...@gmail.com writes: Evil, but this is the solution I use: (let [v (resolve 'a)] (symbol (str (ns-name (.ns v))) (str (.sym v I'd love to know a better way. How about backquote? user= (def x 5) #'user/x user `x user/x Bye, Tassilo --

Re: How to get the namespace for an unqualified symbol?

2012-11-12 Thread Alan Malloy
Yikes! Try ((juxt (comp ns-name :ns) :name) (meta (resolve 'inc))) - name information is stored on the var's meta in a clojure-friendly way - no need to use undocumented behavior on the java internals. On Monday, November 12, 2012 11:05:15 AM UTC-8, Ambrose Bonnaire-Sergeant wrote: Evil, but

Re: How to get the namespace for an unqualified symbol?

2012-11-12 Thread Stuart Sierra
Assuming the symbol is bound to a Var, you can do this: (name (ns-name (:ns (meta (resolve 'x) -S -- 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