On Mar 26, 12:35 am, James Reeves <jree...@weavejester.com> wrote:
> On 25 March 2011 01:05, Terje Dahl <te...@terjedahl.no> wrote:
>
> > In Java, the language forces you to have more or less one class pr
> > class-file, and you are encouraged to group class-files in packages.
> > So, is it as simple as saying that that namespaces are analogous to
> > class-files, and clj-files are analogous to packages?
>
> Typically, each .clj file will have its own namespace. Clojure uses
> the namespace to find where the corresponding .clj file is on the
> classpath.

So, would you say that namespaces are in fact a lot like Python
packages - one pr file - and with the same flexibility of Python's
import-statements:

import foo.bar
from foo import bar
import foo.bar as mything
etc.

What has thrown me, has been the apparent haphazard use of namespaces
in tutorials using REPL ...


> > Also, while we are at it, what are the naming conventions?
> > The same as in Java packages?
> > So I would use:  "no.terjedahl.some.namespace.here" ?
>
> Some people use this convention, but the majority of Clojure libraries
> tend to use the following convention:
>
>   library-name.some.namespaces
>
> For instance, here are some namespaces for the Ring library:
>
>   ring.middleware.params
>   ring.util.response

Ah, but as in Java, the "big official libraries" such as java itself
starts with i.e. java.swing.  But if I was to publish a utilities
library for swing, i would call it no.terjedahl.java.swing, so that it
could be used by me or others as-is, without conflict with java.swing.
So, I tend to agree with Stuart Sierra in his statement: "For naming,
the Java package convention is pretty good at avoiding conflicts."

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