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