In general, a namespace is a container that provides context for the identifiers (names, or technical terms, or words) it holds, and allows the disambiguation of homonym identifiers residing in different namespaces.[1]

For many programming languages, a namespace is a context for their identifiers. In an operating system, an example of namespace is a directory. Each name in a directory uniquely identifies one file or subdirectory, but one file may have the same name multiple[2] times.

The namespace consists generally of words separated by a period ('.'). Although the namespace notation resembles the library notation in Java at a first glance, it differs semantically. So, if you write in Java java.servlet.http, you are using this library; writing java.servlet.* would include also http and any other sublibraries of servlet. This is not the case in namespaces, where a period and asterisk (.*) at the end is not allowed.

As a rule, names in a namespace cannot have more than one meaning; that is, different meanings cannot share the same name in the same namespace. A namespace is also called a context, because the same name in different namespaces can have different meanings, each one appropriate for its namespace.

Following are other characteristics of namespaces:

Below is an example of a namespace in C++:

namespace Box1{
   int boxSide = 4;
namespace Box2{
   int boxSide = 12; 
int main () {
  cout << Box1::boxSide << endl;  //output 4
  cout << Box2::boxSide << endl;  //output 12
  return 0;

See also


  1. ^ "C# FAQ: What is a namespace". C# Online Net. Retrieved 2010-02-23. "A namespace is nothing but a group of assemblies, classes, or types. A namespace acts as a container—like a disk folder—for classes organized into groups usually based on functionality. C# namespace syntax allows namespaces to be nested." 
  2. ^ "C# FAQ: What is a namespace". C# Online Net. Retrieved 2010-02-23. "For instance, [under Windows], to access the built-in input-output (I/O) classes and members, use the System.IO namespace. Or, to access Web-related classes and members, use the System.Web namespace." 

Wikimedia Foundation. 2010.

Look at other dictionaries:

  • Namespace — Namensraum (englisch namespace) ist ein Begriff aus der Informatik. Ein Name identifiziert ein Objekt. Zur eindeutigen Zuordnung ist jedoch der entsprechende Kontext – eben der Namensraum zu beachten. Die Beschreibung geschieht üblicherweise… …   Deutsch Wikipedia

  • namespace —    In Microsoft Active Directory, a collection of unique domain names. A namespace can be contiguous or disjointed. In a contiguous namespace, a child domain always contains the name of the parent, for example, accounting.sybex .com as a… …   Dictionary of networking

  • NameSpace — Espace de noms Pour une explication plus détaillée sur l utilisation du terme dans Wikipédia, voir Aide:Espace de noms. Un espace de noms (namespace) est un ensemble de ce qui est désignable dans un contexte donné par une méthode d accès donnée… …   Wikipédia en Français

  • namespace — 1. noun A conceptual space that groups classes, identifiers, etc. to avoid conflicts with items in unrelated code that have the same names. 2. verb To categorize by placing into a namespace. Something I havent captured in this schema is that the… …   Wiktionary

  • Namespace — …   Википедия

  • Namespace — einheitlicher, verteilter Namensraum, in dem kein Name doppelt vorkommen darf (z.B.: Internet Subnet …   Acronyms

  • namespace — ● ►en n. m. ►XML Voir espace de nommage …   Dictionnaire d'informatique francophone

  • Namespace — einheitlicher, verteilter Namensraum, in dem kein Name doppelt vorkommen darf (z.B.: Internet Subnet …   Acronyms von A bis Z

  • Namespace-based Validation Dispatching Language — (NVDL) is an XML schema language for validating XML documents that integrate with multiple namespaces. It is an ISO/IEC standard, and it is Part 4 of the DSDL schema specification. Much of the work on NVDL is based on the older Namespace Routing… …   Wikipedia

  • Namespace (computer science) — For namespaces in general, see Namespace. A namespace (sometimes also called a name scope) is an abstract container or environment created to hold a logical grouping of unique identifiers or symbols (i.e., names). An identifier defined in a… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”

We are using cookies for the best presentation of our site. Continuing to use this site, you agree with this.