Modules vs name spaces (Was: Global namespace)

Harald Hanche-Olsen hanche at math.ntnu.no
Thu Oct 30 16:35:38 EST 2003


+ gat at jpl.nasa.gov (Erann Gat):

| In article <pco7k2ndcpw.fsf_-_ at thoth.math.ntnu.no>, Harald Hanche-Olsen
| <hanche at math.ntnu.no> wrote:
| 
| > + j-anthony at rcn.com (Jon S. Anthony):
| > 
| > | There's a difference between modules and name spaces, though modules
| > | in many languages also serve as name spaces.
| > [...]
| > So, can anyone either explain the difference, or point to a resource
| > (preferably on the web) that explains it?
| 
| Packages map strings onto symbols (identifier objects).

Agreed.

| Modules map symbols/identifiers onto values.

Okay.

| Packages work at read/parse time.

Yep.

| Modules work at compile time or run time depending on the module system.
| 
| Common Lisp has a package system but no module system (but it's possible
| to add one -- see e.g. http://www.flownet.com/gat/locales.pdf).

Ah.  I had read that one before, but never realized that it describes
a module system.  That gives me some idea what it's all about.
Thanks.

| Python has a module system that works at run-time, but no package system.
| 
| Does that help?

Now I am getting a bit confused once more, since python doesn't have
symbols, and so the distinction between modules and packages gets
blurred (in my mind at least): A python modules maps strings directly
to values without symbols ever entering the discussion.

But the read-time vs run-time (or compile-time) distinction makes more
sense to me.  If a python function references foo.bar then by changing
the value of foo I can make the function refer to a different foo.bar,
but if a Common Lisp function references foo:bar, then messing around
with the FOO package is never going to change the meaning of that
reference.

I guess what I am saying is that, while packages without symbols don't
make sense, modules don't require them.  But then, neither did you
say they do, now that I read what you said over again.

-- 
* Harald Hanche-Olsen     <URL:http://www.math.ntnu.no/~hanche/>
- Debating gives most of us much more psychological satisfaction
  than thinking does: but it deprives us of whatever chance there is
  of getting closer to the truth.  -- C.P. Snow




More information about the Python-list mailing list