Namespace question?

First off, this question has nothing to do with the horrid, nasty, vile myspace site.

Well, I'm tring to find some reason to get out of doing my general ed homework currently...so I'm looking into my old computer programming book for of my classes.

I had a question on namespaces (the language would be in C++, although I seriously doubt it would actually matter what language it is in...anyway) my book lists the "creation" of the names spaces reason as a standard way to get around the global identifier naming thing, where if I had a identifier inside a header file that had the same name as a global identifier in my program, it would generate a compiler error since the global identifiers in the header file become the global identifiers in my program (client file).

Anyway, my question is, is this REALLY that much of a problem enough to build a function for it into the actual language itslef? I understand that if there WAS no such thing as a namespace, i would have to type the

2007-02-10T22:44:40Z

ClassName::membername before referencing every member of a class (and yes I mean by an object). This honeslty would seem like something that should be dealt with by the programmer, so is it really that big of an issue, and why?


Please answer...I don't want to do my general ed homework....please......?!?!?!

2007-02-10T22:46:07Z

Man I spunk the good englishez, I don't needs no object framework!

2007-02-10T22:51:00Z

answer now...

kniemczak2007-02-10T22:57:53Z

Favorite Answer

You are assuming that one programmer is writing all aspects of the code. Also namespaces were not necessarily created because of global variables. Imagine if you had two libraries you purchased from a third party in your application. If you were to import both libraries into your application, but they bot defined a class with the same name you code would produce this error.

Namespaces allow classes, variables, etc to exists with the same name because their scope is limited to the namespce instead of the whole application.

Now if you are writing the entire application it might seem unnecessary, but really it can still be useful.

Andy T2007-02-11T08:33:01Z

Considering the wealth of libraries that would have been tiresome to write all over again, if namespace is not implemented, either in C++, Java, C#, Python, or whatever language, then there is only one person can be in charge of writing the libraries, because someone has to coordinate all the identifiers and names to avoid clashes.

If namespacing is a syntactical feature in a language, the coordination is on namespacing and that could've spread to handled by more than one programmer.

ndp82007-02-11T07:56:42Z

Yes this is an important part of the language. For simple programs, not it's not. For larger ones, with multiple people and integration of external libraries, it becomes necessary. The name-spaces in C++ make this viable.

Look at Java's "packages" (or C#) for the next generation of this. It has really allowed Java to be pluggable, libraries to be upgradeable, and large (huge) programs to be organized and understandable. Much modern software wouldn't be feasible without it.