I've seen people say here that it's relatively easy to break up a
namespace into smaller components, so I'm wondering if I'm missing
something. I'd appreciate some guidance about how to keep namespaces
well-organized.
In Python, let's say I have a library "mylibrary.py", and from various
files I say "from mylibrary import *".
If I want to split mylibrary.py into two parts, say, library1.py and
library2.py, then I can just change mylibrary.py to say:
from library1 import *
from library2 import *
All the functions from library1 and library2 become available to
mylibrary, which in turn becomes available to all files that import
from mylibrary. In other words, nothing breaks by splitting into two
files.
Now in Clojure, let's say I have a file mylibrary.clj and from various
files I say:
(ns a-random-file-that-consumes-my-library
(:use mylibrary))
So now, if I want to split mylibrary.clj into library1.clj and
library2.clj, I change mylibrary.clj to say:
(ns mylibrary
(:use library1 library2))
Unfortunately, this seems to break my consumer code. Although
mylibrary can see the functions from library1 and library2, consumers
of mylibrary cannot. So I end up manually having to go to all my
consumer files and changing them to:
(ns a-random-file-that-consumes-my-library
(:use library1)
(:use library2))
Blech. This makes it very difficult to refactor. What am I missing?
On a related note, another thing I'm missing from Python is that in
mylibrary.py, when I say "from library1 import *", Python
automatically knows to look in the same directory. This keeps the
import declarations nice and short for a group of related files, and
more importantly, they don't break if I rename the directory they are
in or move them around.
On the other hand, I'm finding in Clojure that I need to explicitly
name the directory as part of the namespace, and I'm finding this to
be a nuisance. Is there any way to make this a bit more pleasant?
Thanks.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to
clo...@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+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en