Hi,

Am 30.05.2010 um 16:39 schrieb Sina K. Heshmati:

> [2] 
> http://github.com/sindoc/algorithms/blob/master/src/test/clojure/whiteboard/y2010/hide-adt-state-using-closure.clj

I'm almost sure, that this code does  not what you expect. Nested def's, and in 
particular defn's, are almost surely wrong. You want:

(defn make-module
  []
  (let [state (atom 0)
        say-hello (fn [] (println "Hello"))
        public-op (fn [x y] (+ @state x y))]
    (fn [op]
      (case op
        :hello  say-hello
        :public public-op))))

And I'm not sure with what you mean by "you are not allowed to change the root 
of a Var". Of course you can do that.

(declare x)
(defn fn-using-x ...)
(def x 5)

The declare is also (more or less) equivalent to (def x nil).

But I'm not sure I misunderstand something here.

Sincerely
Meikel

-- 
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 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

Reply via email to