On Monday 22 December 2008 05:55, Mark Volkmann wrote: > On Sun, Dec 21, 2008 at 3:44 PM, Stephen C. Gilardi wrote: > > ... > > I thought that every symbol and keyword was in some namespace, > defaulting to the current namespace when the symbol or keyword is > defined. Since the default namespace in the REPL is user, that's what > I expected. I get the same error though with any symbol that I def. > For example, > > (def n 1) > (namespace n) > java.lang.IncompatibleClassChangeError (NO_SOURCE_FILE:0) > > Shouldn't the namespace of n be user?
Starting with this: user=> (doc namespace) ------------------------- clojure.core/namespace ([x]) Returns the namespace String of a symbol or keyword, or nil if not present. Note that namespace is a function, not a macro or special form. That means its arguments are _always_ evaluated before it is invoked. So in the example you gave is the same as: user=> (namespace 1) java.lang.IncompatibleClassChangeError (repl-1:5) Presumably (as I mentioned earlier) you want to examine the Var associated with the name "n" (as you def'ed in your example): user=> ^#'n {:ns #<Namespace user>, :name n, :file "repl-1", :line 6} user=> (str (:ns ^#'n)) "user" You could create a macro to do this: (defmacro var-namespace-name [v] `(str (:ns ^(var ~v)))) user=> (var-namespace-name n) "user" Randall Schulz --~--~---------~--~----~------------~-------~--~----~ 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 To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---