var vs. symbols

2010-10-11 Thread Ulises
Hi, I'm sure this has been asked before (although I couldn't find anything other than this StackOverflow thread http://stackoverflow.com/questions/2320348/symbols-in-clojure) and, in addition to that thread, I have a clarifying question: Am I right if I say that when I do (def foo 1) I'm

Re: var vs. symbols

2010-10-11 Thread nickikt
you are right (at least as far as I know) -- 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

Re: var vs. symbols

2010-10-11 Thread Laurent PETIT
2010/10/11 Ulises ulises.cerv...@gmail.com Hi, I'm sure this has been asked before (although I couldn't find anything other than this StackOverflow thread http://stackoverflow.com/questions/2320348/symbols-in-clojure) and, in addition to that thread, I have a clarifying question: Am I

Re: var vs. symbols

2010-10-11 Thread Ulises
I guess one should use mapping instead of binding. The var is mapped to the symbol foo in the namespace *ns*. I'm saying that because functions for inspecting namespaces are (ns-map), Ah! Excellent, thanks. U -- You received this message because you are subscribed to the Google Groups

Re: var vs. symbols

2010-10-11 Thread Meikel Brandmeyer
Hi, On 11 Okt., 11:44, Laurent PETIT laurent.pe...@gmail.com wrote: I guess one should use mapping instead of binding. The var is mapped to the symbol foo in the namespace *ns*. I'm saying that because functions for inspecting namespaces are (ns-map), etc. In a determined attempt to

Re: var vs. symbols

2010-10-11 Thread Ulises
So I would say: Unqualified symbols in the namespace the def happened in will resolve to the def'd Var. (of course only after the def happened!) so in theory one could have a symbol foo bound to a var bar? U -- You received this message because you are subscribed to the Google Groups

Re: var vs. symbols

2010-10-11 Thread Meikel Brandmeyer
Hi, On 11 Okt., 12:26, Ulises ulises.cerv...@gmail.com wrote: so in theory one could have a symbol foo bound to a var bar? Eh. No. I don't think so. The Var has a name and the symbol has a name. And an unqualified symbol is resolved to the closest Var with the same name (conveniently derefing

Re: var vs. symbols

2010-10-11 Thread Ulises
Eh. No. I don't think so. The Var has a name and the symbol has a name. And an unqualified symbol is resolved to the closest Var with the same name (conveniently derefing the var to get its contents). This might be in the same namespace or in a different namespace which was :use'd. I'm still

Re: var vs. symbols

2010-10-11 Thread Meikel Brandmeyer
Hi, On 11 Okt., 12:45, Ulises ulises.cerv...@gmail.com wrote: user (def foo) #'user/foo user foo ;Var user/foo is unbound. ;  [Thrown class java.lang.IllegalStateException] user I guess this means there's no var named user/foo and hence the symbol cannot get its closest match in name?

Re: var vs. symbols

2010-10-11 Thread Meikel Brandmeyer
Hi, or a maybe clearer example, which shows the different states: ; No Var, yet. user= (var foo) java.lang.Exception: Unable to resolve var: foo in this context (NO_SOURCE_FILE:1) ; Var is now defined. Hence it can be resolved. But it has to root value, ie. it is unbound, yet. user= (def foo)

Re: var vs. symbols

2010-10-11 Thread Ulises
Hope, that helps. It does indeed. So, def either creates or looks up a var of the name of the symbol given and then every time eval comes across a symbol it tries to lookup a var of the same name? (just read http://clojure.org/special_forms#def which I should've read before posting) Cheers

Re: var vs. symbols

2010-10-11 Thread Meikel Brandmeyer
Hi, On 11 Okt., 13:29, Ulises ulises.cerv...@gmail.com wrote: sorry for the confusion and the silly questions, Ehm. Nope. To cite the (german) sesame street: Wer? Wie? Was? Wieso? Weshalb? Warum? Wer nicht fragt bleibt dumm! Just keep asking. :) Sincerely Meikel -- You received this