On Jan 22, 2009, at 12:46 PM, Paul Henning wrote:
As described, this doesn't work. load-file looks up symbols in the current namespace ("user" in this case), but foo is interned in app.
At some point in this process, Clojure needs to know which foo you're talking about. It can't retrieve the var associated with foo without knowing which namespace it's in. That determination can either be explicit or it can be made via the current namespace (*ns*), but it has to be made somehow.
I found that I could get the behavior I wanted if I changed the definition of reader to: (defn reader [filename] (binding [*ns* (the-ns 'app)] (load-file filename)))
That's one way to say that foo is in namespace app.
But this has a sort of evil feeling to it. Is there a better way of doing this?
Another way is to use symbols with namespaces in "data": (app/foo)Another way is to declare within "data" the namespace in which the symbols it contains should be resolved:
(in-ns 'app) (foo)One nice feature of loading in Clojure is that any namespace changes are reverted at the end of the file. After the repl commands you used in your example, the repl namespace will still be user.
--Steve
smime.p7s
Description: S/MIME cryptographic signature