On Feb 17, 2009, at 5:10 AM, Chouser wrote:
> >> I think that the strict usage is consistent with Clojure's >> "binding" macro, >> which binds a name to a new variable. > > Are you sure? It seems to me the most natural mapping from the CL > concepts to Clojure is: > CL name -> Clojure symbol, name, or perhaps namespace entry > CL variable -> Clojure Var (or perhaps ref, atom, etc.) > CL value or referent -> Clojure value. > > Clojure's 'binding' macro does not change the connection from name to > Var, but the one from Var to (effective, thread-local) value. > I see that you are correct. Observe the following behavior: ; Common Lisp. We have no way to get ahold of the variable (reference) to which a ; name is bound. Dereferencing is automatic. However, with a dynamic ; variable we can access the symbol data structure associated with the name *PUNG*. (defvar *pung* 8) (defvar *foo* *pung*) ; Referent of *PUNG* assigned (defvar *bar* '*pung*) ; Note the quote here--assigning symbol *PUNG* ; Establish a new binding for *PUNG*. *BAR* changed as well. (let ((*pung* 9)) (list *pung* *foo* (symbol-value *bar*))) => (9 8 9) ; Clojure. We can access the reference itself via "var". (def pung 8) (def foo pung) ; i.e., (deref (var pung)) or @#'pung (def bar (var pung)) ; "binding" changes value of "pung"--apparently not the variable itself, thus ; "bar" also reflects changed value. (binding [pung 9] (list pung foo @bar)) => (9 8 9) ; By contrast "let" binds "pung" to a new variable, which shadows the global. ; "bar" still refers to global "pung" (let [pung 9] (list pung foo @bar)) => (9 8 8) Do I have it right now? Aloha, David Sletten --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---