Questions tagged [name-collision]

Within the context of computers and computer programming, "name collision" is the technical term for an instance in which two items have the same name within some logical enclosure. A name collision can occur in many instances, such as with the names of files in a directory, or in a program in which local variables in a function have the same name as some global variables.

The term "name collision" has been used in computer science for more than 3 decades, when referring to names in various classification systems. Most of the time, a name collision must be resolved immediately in some way, whether automatically by an operating system or compiler or manually through user input and decisions. The concept of a namespace sometimes resolves collision issues by creating different logical regions in which items with similar names can co-exist without ambiguity. In certain programming instances, a name collision might not be immediately evident, occasionally leading to hard-to-find program errors that can result from the compiler making certain assumptions about the names of items used.

An example of how a name collision can occur involves two directories full of files. If each directory contains a file named "DATA", and the contents of one directory are copied into the other, then the computer's attempts to copy the file named DATA will find that a file with the same name already exists in the target directory. This creates a name collision. In this instance, the user usually will be prompted and allowed to choose from a list of resolutions, including renaming one of the files, not copying the file or overwriting one of the files.

One commonly used solution for a name collision is the implementation of namespaces. A namespace is simply a way to define an area under which object names are contained. In the above example, a directory technically is a namespace, meaning multiple files can all have the same name as long as they are each in different directories.

From a programming perspective, a name collision can occur in situations such as multiple inheritance, overlapping variable scopes, or even with imported libraries in some languages. In general, a compiler will notice a conflict and generate a warning or error, although this might not always be the case. Other than using namespaces, collisions in many programming languages can be avoided by using qualifiers. A qualifier usually is a prefix that can be placed in front of a variable or class name to distinguish it from another variable with the same name.

75 questions
1
vote
0 answers

R: A better conflicts() function?

For my current project I have the base and tidyverse packages loaded and about 14 more, and I occasionally worry about bugs from potential conflicts which I have missed. I have just learned of the conflicts() function, which I think is intended to…
andrewH
  • 2,281
  • 2
  • 22
  • 32
1
vote
0 answers

Is it allowed to import (via use) a class from a different namespace in PHP when it collides with a class in current namespace?

When using use to import/alias namespace into current namespace in PHP - is it allowed to import to the name of a class that does exist in current namespace but isn‘t used in the current file? PHP 5.6 and 7.x seem to behave differently here.…
undko
  • 927
  • 8
  • 15
1
vote
1 answer

$assertionsDisabled and javac standards compliance

I was wondering how assertions were implemented. I found that javac uses a static field $assertionsDisabled. And I was curious what will happen if $assertionsDisabled is already used. public class Test { static final boolean $assertionsDisabled…
1
vote
1 answer

Clojure in Action, Ch 12 Data Analysis example, dependency issues

I am working through the first edition of this book and while I enjoy it, some of the examples given seem out-dated. I would give up and find another book to learn from, but I am really interested in what the author is talking about and want to make…
1
vote
1 answer

Is it ok to have 2 controls in 2 different forms/usercontrols to have the same name?

Let's say I have declared a oledDbAdapter1 in Form1, and another in Form2 with exactly the same name. Will this cause any conflict?
Nerdsworth
  • 51
  • 1
  • 6
1
vote
0 answers

Namespace and Class names conflict

I have a class called Functions which is in the namespace, let's say SomeNameSpace. In the Functions class I have a function called GetCurrentValue which I am using to create an excel formula to display in the formula bar. I want the formula…
Nelly Sugu
  • 146
  • 7
0
votes
2 answers

Android Compilation Error, Type is defined multiple times

I need to build a library with android studio and here is my configuration: A project with 2 modules: 1/App: Application Module containing an application to test my library 2/MyLibrary: Library Module, containing the library i'm working on. Each of…
momone50
  • 47
  • 8
0
votes
1 answer

How do I ensure my MSBuild properties are not already defined somewhere else?

Is there a way to know if the name for a MSBuild property I want to create is not already being used somewhere else in my solution? How do I create MSBuild customizations that are safe from property name conflicts? For context, I just spent several…
julealgon
  • 7,072
  • 3
  • 32
  • 77
0
votes
1 answer

What places other than sys.path python looks for when importing a package

Scenario From a package let's say beta: After modifying the sys.path, importing a package alpha then reverting the sys.path. I try to import a module data_provider that exists in both alpha and beta The issue is: the data_provider in alpha gets…
weshouman
  • 632
  • 9
  • 17
0
votes
1 answer

Conflicting user defined class name with inbuilt class name - C#

I have the following code, where I am using the inbuilt C# Stack class in my own user defined Stack1 class. Everything works well with this user defined nomenclature. But, as soon as I change all references of my user defined Stack1 class, and call…
Vikram Singh
  • 435
  • 2
  • 10
0
votes
1 answer

Python package names collision

I have a following project structure: program_name/ __init__.py __main__.py package_name/ __init__.py some_module.py when I run python program_name from top level directory I get an error. It appears, that some of mine…
Yaroslav Kishchenko
  • 475
  • 1
  • 4
  • 15
0
votes
0 answers

How does ODR apply to classes declared in cpp files?

I just had strange effects in my program because of two different classes with the same name in two different cpp files of a DLL. I thought that code in cpp files does not influence code in other cpp files, but this is obviously wrong. Is it true…
Fabian
  • 4,001
  • 4
  • 28
  • 59
0
votes
1 answer

Reset/Reload IFrame JavaScript context

I am creating an interactive code editor that consists of a text box and an