Thanks Rasmus, Meikel,

This does help a lot already.

There still seems to be an issue with using some of the things,
though. When I do

  (require '(my-important-project core analysis-2))

I would logically do (in-ns 'my-important-project.analysis-2) because
that's where all the functions are that I actually have to call.

I am then still able to print out the some-constant from core by

  (println my-important-project.core/some-constant)

but it seems that this does not work for the congomongo connection to
a mongodb database (also referred to in the core.clj file):

  (println (my-important-project.core/fetch-one :data)) ; => No such
var: my-important-project.core/fetch-one

For this to work I have to reference the underlying
"somnium.congomongo" directly instead of my-important-project.core:

  (println (somnium.congomongo/fetch-one :data)) ; => works

Is there a way to make "fetch-one" and "some-constant" available
within the analysis-2 namespace using their unqualified names? What
about defining the namespace at the top of the analysis-2.clj file
like this?

  (ns my-important-project.analysis-2
      (:use [my-important-project core]))

and just saying (require '(my-important-project analysis-2)) in the
repl (so without mentioning core)? This *does* make it possible to get
to "some-constant" directly, but still no luck with the congomongo
(fetch-one) function.

I don't understand why... If congomongo is "used" within core and core
is "used" within analysis-2, this does not mean that the congomongo
functions are available in analysis-2 without explicit calling of
congomongo? That would be unfortunate, because I'd have to start
"using" congomongo in several places, as well as incanter and other
libraries...

jan.


On Aug 17, 1:10 pm, Meikel Brandmeyer <m...@kotka.de> wrote:
> Hi,
>
> On 17 Aug., 13:39, Rasmus Svensson <r...@lysator.liu.se> wrote:
>
> > (in-ns 'my-important-project.analysis-2)
>
> > or simply use the ns macro:
>
> > (ns my-important-project.analysis-2)
>
> Please note, that these two are *not* equivalent!
>
> With ns:
>
> Clojure 1.1.0
> user=> (ns foo.bar (:refer-clojure :exclude (map)))
> nil
> foo.bar=> (def map 5)
> #'foo.bar/map
> foo.bar=> (in-ns 'user)
> #<Namespace user>
> user=> (ns foo.bar)
> java.lang.IllegalStateException: map already refers to: #'foo.bar/map
> in namespace: foo.bar (NO_SOURCE_FILE:4)
>
> With in-ns:
> Clojure 1.1.0
> user=> (ns foo.bar (:refer-clojure :exclude (map)))
> nil
> foo.bar=> (def map 5)
> #'foo.bar/map
> foo.bar=> (in-ns 'user)
> #<Namespace user>
> user=> (in-ns 'foo.bar)
> #<Namespace foo.bar>
>
> ns should really only be used to define a namespace. Then you should
> use in-ns to switch namespaces in the Repl (or to ensure we are in the
> right namespace at the top of a file, which is sucked in via load).
>
> 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