On Jan 26, 10:29 pm, Cosmin Stejerean <cstejer...@gmail.com> wrote:
> Can you help me understand the difference between this and use (or :use in
> ns)?

use is internal to the current namespace. You can use other namespaces
without their publics being added to the current namespace. So:

=> (ns a)
=> (def x 10)
=> (ns b (:refer a))
=> x
10
=> (ns c (:refer b))
=> x
java.lang.Exception: Unable to resolve symbol: x in this context

You can see that just because b refers to a, it doesn't mean that c
gets x by referring to b. This is usually what you want, as you don't
want your namespaces to be cluttered up every time you call use or
refer. However, for libraries with lots of namespaces, sometimes you
want to group very specific namespaces into more generic packages, and
that's what immigrate does:

=> (ns a)
=> (def x 10)
=> (ns b)
=> (immigrate 'a)
=> x
10
=> (ns c (:refer b))
=> x
10

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