Hi Achim,
I think I understand now.
> It's important to note that, regardless of the lexical context, def(n)
> creates global/top-level definitions (contrary to scheme, i believe).
>
(defn create-a [firstName lastName]
(defn getFirstName [] firstName)
(defn getLastName [] lastName)
(fn [operator & operands]
(apply operator operands)))
(def t (create-a "Kurt" "Z"))
(def r (create-a "Bob" "hope"))
(t getFirstName)
--> returns "Bob" instead of "Kurt"
And this is the case because despite where defn is declared, it is a
top level definition in the current name space. Thus calling "def r"
above redefines getFirstName and getLastName.
Thanks for clearing this up.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---