Oops your right. Perhaps this will work for you then.
;; gravity.clj (note we don't define an ns)
;; ===============================================
(def *gravity* 1.0)
(defn say-grav [grav]
 (prn "Gravity is:" grav))

(defn halve-grav []
 (/ *gravity* 2.0))

(defn mult-grav [x]
 (* *gravity* x))

(defn print-grav-stats []
 (say-grav *gravity*)
 (say-grav (halve-grav))
 (say-grav (mult-grav 2)))

;; module_a.clj
;; ===============================================
(ns module-a)
(load "gravity")

;; module_b.clj
;; ===============================================
(ns module-b)
(load "gravity")

(def *gravity* 0.38)
(defn say-grav [grav]
 (prn "Gravity on Mars is:" grav))

;; consumer.clj
;; ===============================================
(ns consumer
  (:require [module-a :as a])
  (:require [module-b :as b]))

(a/print-grav-stats)
(b/print-grav-stats)


On Mon, May 18, 2009 at 12:11 AM, Mark Engelberg
<mark.engelb...@gmail.com>wrote:

>
> On Sun, May 17, 2009 at 8:12 PM, David Nolen <dnolen.li...@gmail.com>
> wrote:
> > Have you looked at the immigrate function in Compojure? This imports
> public
> > vars from a different namespace into a namespace as if they were defined
> > there.  Maybe this is enough to get the behavior that you want?
>
> Not really.  Consider the following:
> (ns testns1)
> (def a 2)
> (defn b [] a)
>
> Then:
> (ns testns2)
> (immigrate 'testns1)
> ; Let's try to redefine global variable a
> (def a 4)
>
> (testns2/b) will still return 2.  That's because even though b has
> been "immigrated" to the testns2 namespace, the var a in the body of b
> still refers to testns1/a.
>
> So no, I don't really see how immigrate helps.
>
> >
>

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

Reply via email to