On Tue, Jan 27, 2009 at 8:51 AM, Mark Volkmann <r.mark.volkm...@gmail.com> wrote: > > Are these statements correct? Actually, I know some are correct > because I just looked though the source. Hopefully others that haven't > will find this interesting. > > Symbol objects have a String name and a String namespace name, but no value. > Var objects have references to a Symbol object, a Namespace object and > an Object object which is its "root value". > Namespace objects have a reference to a Map that holds associations > between Symbol objects and Var objects. > In Clojure, the term "interning" typically refers to adding a > Symbol-to-Var mapping to a Namespace.
Those all sound right to me, with the (very minor) caveat that Namespaces also have a aliases map. > Why don't Symbol objects have a reference to a Namespace object > instead of a String that is a Namespace name? The namespace part of a symbol doesn't have to refer to any existing namespace. This is useful for example when using the symbol as its own value. user=> (namespace 'foo/bar) "foo" The namespace part can even be 'nil', which is probably the most common case for symbols created by the reader: user=> (def expr (read (java.io.PushbackReader. (java.io.StringReader. "(+ 1 2)")))) user=> (first expr) + user=> (namespace (first expr)) nil Or even just: user=> (namespace 'zipmap) nil --Chouser --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---