Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

D
Lv 4

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

Update:

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......?!?!?!

Update 2:

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

Update 3:

answer now...

3 Answers

Relevance
  • 1 decade ago
    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 T
    Lv 7
    1 decade ago

    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.

  • 1 decade ago

    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.

Still have questions? Get your answers by asking now.