Namespace

Namespace

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

References

  1. ^ "C# FAQ: What is a namespace". http://en.csharp-online.net/: C# Online Net. http://en.csharp-online.net/CSharp_FAQ:_What_is_a_namespace. 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". http://en.csharp-online.net/: C# Online Net. http://en.csharp-online.net/CSharp_FAQ:_What_is_a_namespace. 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 — 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-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

  • Namespace-based Validation Dispatching Language — Die Namespace based Validation Dispatching Language (NVDL) ist eine XML Schemasprache zum Validieren von XML Dokumenten, deren Struktur mit verschiedenen Schemasprachen und in unterschiedlichen Namensräumen definiert wurde. NVDL ist ein ISO/IEC… …   Deutsch Wikipedia

  • Namespace Routing Language — In its simplest form, a Namespace Routing Language (NRL) schema consists of a mapping from namespace URIs to schema URIs. An NRL schema is written in XML. DSDL Part 4 (ISO/IEC 19757 4), NVDL is based on NRL. External links NRL home page NVDL… …   Wikipedia

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

Share the article and excerpts

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