Global namespace (was Re: python libs v lisp coolness?

Jon S. Anthony j-anthony at rcn.com
Wed Oct 29 14:15:03 EST 2003


Ville Vainio <ville.spammehardvainio at spamtut.fi> writes:

> Paolo Amoroso <amoroso at mclink.it> writes:
> 
> > The lack of Lisp libraries is being addressed.
> 
> Are they also going to address the lack of modules? The way I've seen
> Lisp used, everything is dumped into a global namespace (even
> "methods" in CLOS). I shudder at the thought of using Python where all
> the names from various modules would be in the global namespace.

There's a difference between modules and name spaces, though modules
in many languages also serve as name spaces.  The issue you are
talking about here really is a name space issue and Common Lisp has
had control over that from the start.  Its construct is the _package_.

> in Python you can do:
> 
> import os
> 
> files = os.listdir("/root")

In Common Lisp this is basically the same.  The symbols from OS that
should be public are _exported_.  You then can access them, for
example, as:


(os:listdir "/root")


You can also _use_ a package if you are in another so that the
_exported_ symbols become visible w/o qualification.

(use-package :os)

...

(listdir "/root")


There are a lot of other things for controlling visibility of this
sort.  For example, you can _import_ only specific symbols or you can
_shadow_ others, etc.



/Jon




More information about the Python-list mailing list