what's so difficult about namespace?

Robert Maas, http://tinyurl.com/uh3t seeWebInstead at teh.intarweb.org
Fri Nov 28 03:33:11 EST 2008


> From: Kaz Kylheku <kkylh... at gmail.com>
> Scheme hasn't officially supported breaking a program into
> multiple files until R6RS. If the language is defined in terms of
> one translation unit, it doesn't make sense to have a namespace
> feature.

Good point. Note that any language that uses optionally-loadable
"libraries" automatically has more than one translation unit,
namely the application itself and at least one loaded library. More
on this later.

> Javascript programs are scanned at the character level by the
> browser as part of loading a page.  So there are severe practical
> limitations on how large Javascript programs can be.

That's only half the reason. The other half is that JavaScript
doesn't support requiring additional libraries to be downloaded
from another site to be added to the main JavaScript application,
right?

> Namespaces are useful only in very large programs.

Or in medium sized programs that require loading libraries written
by other people, of the total set of all such libraries is too
large to globally manage well enough to avoid name clashes. The
main program might not use namespaces internally, but the various
libraries *must* use namespaces internally, and then the main
program must arrange for external functions to be propertly called
with namespace+localname.

> The essence of a true namespace or package system or whatever is
> that you can establish situations in which you use the unqualified
> names.

Correct.

> You can emulate namespaces by adding prefixes to identifiers,
> which is how people get by in C.

With the pain that you must always use the fully-qualified name, right?

> In C, you can even get the functionality of short names using the
> preprocessor.

I hear Greenspun there! :-)

> I have done this before (but only once). ...

(Story of a Greenspun task. Yes, I agree what you did, after the
 fact, to avoid needing to manually edit all the files in your
 source to have fully-qualified names when porting for others to
 use, was a reasonable hack.)

> I recently read about a very useful theory which explains why
> technologies succeed or fail.
> See: http://arcfn.com/2008/07/why-your-favorite-programming-language-is-unpopular.html
404 not found.

Otherwise this thread, and your article in it, are interesting and
enlightening. BTW comp.lang.lisp is my favorite newsgroup for
articles that give new insight I overlooked before. KentP and
PascalB have the largest amount of good insight, but other posters
contribute too. Thanks for posting Kaz et al. (I hope once in a
while something I post provides enlightening insight to somebody.)



More information about the Python-list mailing list