Posts by Jorge Duenas

01 Jan 2010, 16:50
Generic-user-small

Jorge Duenas (1 post)

(from Programming Clojure > Example on Page 16 - Side Effects?)

Hello,

I am a Clojure beginner puzzled by the following snippet (from Chapter 1, “Adding Shared State”; can also be found at the bottom of introduction.clj):

(def visitors (ref #{}))

(defn hello 

  [username]
  (dosync 
    (let [past-visitor (@visitors username)]    ; <--------- visitors is a global!

  ; etc ....

I mean, hello depends in a not-so-obvious way from the global reference <a href="mailto:visitors”>visitors@. Wouldn’t it be better to pass visitors as a further parameter to hello?

Jorge

1 post