On Fri, Jan 23, 2009 at 7:56 AM, zoglma...@gmail.com <zoglma...@gmail.com> wrote: > >> 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)))
It's also worth noting that this is very much discouraged, as it means that create-a has poorly controlled global side-effects. If you want locals named 'getFirstName' and 'getLastName', please use 'let' instead of 'defn': (defn create-a [firstName lastName] (let [getFirstName (fn [] firstName) getLastName (fn [] lastName)] ...)) However, if you mean to be changing global state, look into using any of the well-managed state mechanisms, such as 'ref', 'agent', 'atom', or Vars: http://clojure.org/concurrent_programming Also, CamelCase is discouraged unless required for interop with Java or something else. Clojure allows names like first-name and get-last-name, so that format is preferred. --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 -~----------~----~----~----~------~----~------~--~---