In
computer programming
Computer programming is the process of performing a particular computation (or more generally, accomplishing a specific computing result), usually by designing and building an executable computer program. Programming involves tasks such as anal ...
, a name collision is the
nomenclature
Nomenclature (, ) is a system of names or terms, or the rules for forming these terms in a particular field of arts or sciences. The principles of naming vary from the relatively informal conventions of everyday speech to the internationally agre ...
problem that occurs when the same
variable name is used for different things in two separate areas that are joined, merged, or otherwise go from occupying separate
namespace
In computing, a namespace is a set of signs (''names'') that are used to identify and refer to objects of various kinds. A namespace ensures that all of a given set of objects have unique names so that they can be easily identified.
Namespaces ...
s to sharing one. As with the
collision
In physics, a collision is any event in which two or more bodies exert forces on each other in a relatively short time. Although the most common use of the word ''collision'' refers to incidents in which two or more objects collide with great fo ...
of other
identifier
An identifier is a name that identifies (that is, labels the identity of) either a unique object or a unique ''class'' of objects, where the "object" or class may be an idea, physical countable object (or class thereof), or physical noncountable ...
s, it must be resolved in some way for the new
software
Software is a set of computer programs and associated software documentation, documentation and data (computing), data. This is in contrast to Computer hardware, hardware, from which the system is built and which actually performs the work.
...
(such as a
mashup
Mashup may refer to:
* Mashup (culture), the rearrangement of spliced parts of musical pieces as part of a subculture
* Mashup (education), combining various forms of data and media by a teacher or student in an instructional setting
* Mashup (mus ...
) to work right.
[
"Getting Started" (lesson for C++), Brown University,
Computer Science Dept., January 2000 (in text as "Jan 2000"),
pages 5-6, webpage (PDF):
]
CS-Brown-Cpp
Problems of name collision, and methods to avoid them, are a common issue in an introductory level analysis of
computer languages
A computer language is a formal language used to communicate with a computer. Types of computer languages include:
* Construction language – all forms of communication by which a human can specify an executable problem solution to a compu ...
, such as for
C++.
[
__TOC__
]
History
The term "name collision" has been used in computer science for more than three decades, when referring to names in various classification systems.[
"Name collision in multiple classification hierarchies",
Portal ACM (]Association for Computing Machinery
The Association for Computing Machinery (ACM) is a US-based international learned society for computing. It was founded in 1947 and is the world's largest scientific and educational computing society. The ACM is a non-profit professional member ...
),
by J.L. Knudsen, 1988, webpage:
Portal-ACM-607
Avoiding name collisions
There are several techniques for avoiding name collisions, including the use of:
* ''namespace
In computing, a namespace is a set of signs (''names'') that are used to identify and refer to objects of various kinds. A namespace ensures that all of a given set of objects have unique names so that they can be easily identified.
Namespaces ...
s'' - to qualify each name within a separate name group, so that the totally qualified names differ from each other.[
* ''renaming'' - to change the name of one item (typically the one used less often) into some other name.
* ''prefixing'' - putting unique characters before the names so that the names differ and further name collisions are unlikely to happen by accident.
]
See also
* local variables, variable data items that are local to a module
* Name mangling
In compiler construction, name mangling (also called name decoration) is a technique used to solve various problems caused by the need to resolve unique names for programming entities in many modern programming languages.
It provides a way of e ...
* Naming collision
A naming collision is a circumstance where two or more identifiers in a given namespace or a given scope cannot be unambiguously resolved, and such unambiguous resolution is a requirement of the underlying system.
Example: XML element names
In ...
Notes
References
Programming language design
Information theory
{{prog-lang-stub