Namespace
Encyclopedia
In general, a namespace is a container that provides context for the identifiers (name
Name
A name is a word or term used for identification. Names can identify a class or category of things, or a single thing, either uniquely, or within a given context. A personal name identifies a specific unique and identifiable individual person, and may or may not include a middle name...

s, or technical terms, or word
Word
In language, a word is the smallest free form that may be uttered in isolation with semantic or pragmatic content . This contrasts with a morpheme, which is the smallest unit of meaning but will not necessarily stand on its own...

s) it holds, and allows the disambiguation of homonym
Homonym
In linguistics, a homonym is, in the strict sense, one of a group of words that often but not necessarily share the same spelling and the same pronunciation but have different meanings...

 identifiers residing in different namespaces.

For many programming languages, a namespace is a context for their identifier
Identifier
An identifier is a name that identifies either a unique object or a unique class of objects, where the "object" or class may be an idea, physical [countable] object , or physical [noncountable] substance...

s. 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 times.

The namespace consists generally of words separated by a period ('.'). Although the namespace notation resembles the library notation in Java
Java (programming language)
Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...

 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:
  • Names in the namespace can represent objects as well as concept
    Concept
    The word concept is used in ordinary language as well as in almost all academic disciplines. Particularly in philosophy, psychology and cognitive sciences the term is much used and much discussed. WordNet defines concept: "conception, construct ". However, the meaning of the term concept is much...

    s, be the namespace a natural or ethnic language, a constructed language
    Constructed language
    A planned or constructed language—known colloquially as a conlang—is a language whose phonology, grammar, and/or vocabulary has been consciously devised by an individual or group, instead of having evolved naturally...

    , the technical terminology
    Technical terminology
    Technical terminology is the specialized vocabulary of any field, not just technical fields. The same is true of the synonyms technical terms, terms of art, shop talk and words of art, which do not necessarily refer to technology or art...

     of a profession, a dialect
    Dialect
    The term dialect is used in two distinct ways, even by linguists. One usage refers to a variety of a language that is a characteristic of a particular group of the language's speakers. The term is applied most often to regional speech patterns, but a dialect may also be defined by other factors,...

    , a sociolect
    Sociolect
    In sociolinguistics, a sociolect or social dialect is a variety of language associated with a social group such as a socioeconomic class, an ethnic group, an age group, etc....

    , or an artificial language (e.g., a programming language
    Programming language
    A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....

    ).
  • In the Java programming language
    Java (programming language)
    Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...

    , identifiers that appear in namespaces have a short (local) name and a unique long "qualified" name for use outside the namespace.
  • Some compilers (for languages such as C++
    C++
    C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...

    ) combine namespaces and names in a process called name mangling
    Name mangling
    In compiler construction, name mangling is a technique used to solve various problems caused by the need to resolve unique names for programming entities in many modern programming languages....

    .


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

  • 11-Digit Delivery point
    Delivery point
    In a postal system, a delivery point is a single mailbox or other place at which mail is delivered. It differs from a street address, in that each address may in fact have several delivery points, such as an apartment flat, office department, or other room...

     ZIP code
    ZIP Code
    ZIP codes are a system of postal codes used by the United States Postal Service since 1963. The term ZIP, an acronym for Zone Improvement Plan, is properly written in capital letters and was chosen to suggest that the mail travels more efficiently, and therefore more quickly, when senders use the...

  • Binomial nomenclature
    Binomial nomenclature
    Binomial nomenclature is a formal system of naming species of living things by giving each a name composed of two parts, both of which use Latin grammatical forms, although they can be based on words from other languages...

     (genus-species in biology
    Biology
    Biology is a natural science concerned with the study of life and living organisms, including their structure, function, growth, origin, evolution, distribution, and taxonomy. Biology is a vast subject containing many subdivisions, topics, and disciplines...

    )
  • Chemical nomenclature
  • Dewey Decimal Classification
    Dewey Decimal Classification
    Dewey Decimal Classification, is a proprietary system of library classification developed by Melvil Dewey in 1876.It has been greatly modified and expanded through 23 major revisions, the most recent in 2011...

  • Digital object identifier
    Digital object identifier
    A digital object identifier is a character string used to uniquely identify an object such as an electronic document. Metadata about the object is stored in association with the DOI name and this metadata may include a location, such as a URL, where the object can be found...

  • Domain name system
    Domain name system
    The Domain Name System is a hierarchical distributed naming system for computers, services, or any resource connected to the Internet or a private network. It associates various information with domain names assigned to each of the participating entities...

     (DNS) names (Internet
    Internet
    The Internet is a global system of interconnected computer networks that use the standard Internet protocol suite to serve billions of users worldwide...

     addresses)
  • IP address
    IP address
    An Internet Protocol address is a numerical label assigned to each device participating in a computer network that uses the Internet Protocol for communication. An IP address serves two principal functions: host or network interface identification and location addressing...

  • Library of Congress Classification
    Library of Congress Classification
    The Library of Congress Classification is a system of library classification developed by the Library of Congress. It is used by most research and academic libraries in the U.S. and several other countries; for example, Australia and Taiwan, R.O.C. It is not to be confused with the Library of...


:Category:National identification numbers
  • Star catalogue
    Star catalogue
    A star catalogue, or star catalog, is an astronomical catalogue that lists stars. In astronomy, many stars are referred to simply by catalogue numbers. There are a great many different star catalogues which have been produced for different purposes over the years, and this article covers only some...

    s and astronomical naming conventions
    Astronomical naming conventions
    In ancient times, only the Sun and Moon, a few hundred stars and the most easily visible planets had names. Over the last few hundred years, the number of identified astronomical objects has risen from hundreds to over a billion, and more are discovered every year...

  • XML Namespace
    XML Namespace
    xmlns tagged XML namespaces are used for providing uniquely named elements and attributes in an XML document. They are defined in a W3C recommendation. An XML instance may contain element or attribute names from more than one XML vocabulary...

    s
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK