Hi Alex, first of all thank your this exhaustive explanation.
I still don't get some things, though, and kindly ask for more enlightenment. On Nov 8, 3:46 am, Alex Osborne <a...@meshy.org> wrote: > So after resolving, it then has a Var object. A Var, is as it's > name suggests, a variable. It consist of a name (symbol+ > namespace),metadatamap and a value (called the binding). As far as the documentation says, Vars can't have metadata: "Symbols and collections support metadata," -- http://clojure.org/metadata "Symbols, Lists, Vector, Sets and Maps can have metadata" -- http://clojure.org/reader I tried to understand the Java implementation underneath which seems to be in line with the documentation. E.g. a symbol extends AFn, which extents Obj which implements IObj, which in turn extends IMeta which seems to be the relevant implementation of the metadata interface. However, there is some metadata code in Var.java which indicates that Vars *can* have metadata, but according to documentation they can't. An example also seems to indicate that Vars can have metadata: user=> (def #^{:hasmeta "yes"} my-var [1 2 3]) #'user/my-var user=> (meta my-var) nil user=> (meta (var my-var)) {:ns #<Namespace user>, :name my-var, :file "NO_SOURCE_PATH", :line 63, :hasmeta "yes"} > Now formetadata"on" functoins. When you write this: > > (defn #^{:xxx 1} greet [] "hello") > > The #^{...} syntax means that Clojure creates a list of two symbols > (defn and greet), and empty vector and a string "hello". The second symbol > greet has > the metadata{:xxx 1} associated with it. Really? Then why the metadata of the symbol empty? user=> (meta 'greet) nil Or am I not accessing the symbol's metadata that way? This question is also related to the following part of your explanation. > The greet symbol still keeps it's metadata. Now the def special form: > > 1. Creates a var. > 2. Copies the metadata{:xxx 1} from the symbol greet to the var. > 3. Binds the var to the function (fn ([] "hello")). > 4. Creates a mapping in the current namespace ("user") from the symbol > greet to the var. All items agreed, except for 2. which I don't grok yet. I think for me it boils down to * Is the documentation wrong or my understanding of it? * What part of the (Java)-code should I read to understand the implementation of metadata (if I assume that my understanding of how the classes extent/implement is not correct). The reason for asking this is, that I *really* want to understand what I am talking about. Kind regards, Stefan -- 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 moderated - please be patient with your first post. 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