On Mar 24, 2009, at 10:49 AM, Mark Volkmann wrote:
On Tue, Mar 24, 2009 at 9:44 AM, Stephen C. Gilardi <squee...@mac.com> wrote:

One thing to note is that namespace names should always have at least one period in them. I believe this is due to a rule regarding Java packages. At some point the "clojure" namespace became "clojure.core" for this reason. I haven't had a problem with such "top level" namespace names on my machine
locally, but they're not officially supported.

I hadn't run across that rule before. I guess the "user" namespace is
an exception. That should be mentioned at
http://clojure.org/namespaces. Where did you find that?

It turns out not to be a Java package name rule, but a consequence of how Clojure maps namespaces into Java. A Clojure namespace maps to a Java class. If the namespace has only one component in its name, the class that implements it will be not be in any package. It's classes at the top level (outside of any package) that may cause a problem.

Rich's description here:

        http://groups.google.com/group/clojure/msg/58e3f8e5dfb876c9

includes:

The main structural change related to AOT is that the mapping between
a Clojure namespace and a Java package has changed. Where it was ns
maps to package:

my.fancy.lib ==> my/fancy/lib/lib.clj

it is now ns maps to class:

my.fancy.lib ==> my/fancy/lib.clj, when compiled, my/fancy/lib.class

Just lift your files up a directory to accommodate this change. Note
that this implies that all namespaces should have at least 2 segments,
and following the Java package name guidelines, e.g.
com.mydomain.mylib, is recommended.

Accordingly, the clojure ns has been renamed clojure.core. Any
explicitly qualified references will need to be changed. boot.clj has
been renamed core.clj.

He uses the word "should" there and that's consistent with it working OK in some cases, but it's a guideline that we should encourage and follow.

I agree this should be mentioned on the namespaces page at clojure.org.

--Steve

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to