Ambiguity can refer to two related concepts: 'ambiguous calls' and 'ambiguous grammars'.
Questions tagged [ambiguity]
400 questions
16
votes
3 answers
Context-sensitivity vs Ambiguity
I'm confused about how context-sensitivity and ambiguity influence each other.
What i think is correct is:
Ambiguity:
An ambiguous grammar leads to the construction of more than one parse-tree using either left or right derivation. A language where…

user764754
- 3,865
- 2
- 39
- 55
14
votes
3 answers
C++: How to prevent private names from polluting derived types?
I was shocked today by the fact that this code snippet has an ambiguous name reference:
class A
{
private:
typedef int Type;
};
class B
{
public:
typedef int Type;
};
class D : A, B
{
Type value;//error: reference to 'Type' is…

zwhconst
- 1,352
- 9
- 19
14
votes
3 answers
Solving QT's QString arg() ambiguity
There is an issue using QString::arg() when a string contains a digit right after a place marker. It's not clear from the QString::arg() function description what would happen in case of such a replacement:
QString("String for replacement…

Oleg Yakovenko
- 263
- 3
- 10
13
votes
4 answers
How can there be ambiguity between a property getter and a method with one argument?
I can't believe I've never come across this before, but why am I getting a compiler error for this code?
public class Main
{
public Main()
{
var ambiguous = new FooBar(1);
var isConfused = ambiguous.IsValid; // this call is…

devuxer
- 41,681
- 47
- 180
- 292
13
votes
2 answers
Template function call ambiguity error
I am not familiar with templates. I've just started learning it. Why I am getting errors in following program?
#include
#include
using std::cout;
using std::string;
template
C min(C a,C b) {
return a

Destructor
- 14,123
- 11
- 61
- 126
11
votes
2 answers
Why does IList<>.Reverse() not work like List<>().Reverse
I have problem with List.Reverse() and Reverse(this IEnumerable source).
Look to the code:
// Part 1
List list = new List { 1, 2, 3 };
foreach (int x in list)
Console.Write(x);
Console.WriteLine();
…

AndreyAkinshin
- 18,603
- 29
- 96
- 155
11
votes
1 answer
Why does direct list initialization causes ambiguity for type reference cast if cast operators to the type and reference to the type are declared?
The question rose in context of this answer.
Consider an example:
struct foo {
int value;
operator int&(){ return value; }
operator int(){ return value; }
};
int main () {
int &a(foo{}); // #1
//int &b{foo{}}; // #2 --…

W.F.
- 13,888
- 2
- 34
- 81
11
votes
1 answer
Why is it illegal for non-templated functions to have same name and arguments but different return types? (but legal for template functions?)
I looked a few related stack overflow threads such as This case of template function overloading eludes my understanding
and
Function overloading by return type?
but neither seem to give me precisely the answer I'm looking for, at least not in a…

user1609012
- 191
- 8
10
votes
2 answers
Why Oracle 10g doesn't complain about column ambiguity?
I'm using Oracle 10g (XE 10.2.0.1.0), and find a behavior that I don't understand:
select *
from employees manager
join employees worker on MANAGER.EMPLOYEE_ID = WORKER.MANAGER_ID
join departments on DEPARTMENTS.manager_id = 108
where
…

Sapience
- 1,545
- 3
- 14
- 24
10
votes
1 answer
Is it possible to generically implement the amb operator in D?
Is it possible to generically implement the amb operator in D?
http://www.haskell.org/haskellwiki/Amb
http://www.randomhacks.net/articles/2005/10/11/amb-operator
The sort of thing I'm thinking of is:
amb([1, 2]) * amb([3, 4, 5]) == amb([3, 4, 5, 6,…

fadedbee
- 42,671
- 44
- 178
- 308
10
votes
2 answers
Disambiguate class-member in multiple inheritance
Suppose I have this variadic base class-template:
template
class Base
{
public:
// The member foo() can only be called when its template
// parameter is contained within the Types ... pack.
template
…

JorenHeit
- 3,877
- 2
- 22
- 28
10
votes
2 answers
Function equality and ordering in Erlang
What does it mean to compare functions in Erlang with the operators =:=,==,<,>,=<,>=?
I was playing around with the interpreter and got these results:
Eshell V5.9.2 (abort with ^G)
1> X = fun() -> {} end.
#Fun
2> Y = fun() ->…

megazord
- 3,210
- 3
- 23
- 31
9
votes
1 answer
Why are these arguments ambiguous for a class constructor overload but not ambiguous for a function overload?
The issue is easily resolved by not being an implicit conversion fiend, but it seems like a strange inconsistency to me. Here's an example:
#include
void test1(int a, int b); // Overloaded function with two different
void…

John Schock
- 126
- 4
9
votes
4 answers
Avoiding Over-Use of Namespaces
My library uses several nested namespaces, laid out like the following:
Library name
Class name 1
Class name 2
Class name 3
[...]
Utilities
Class name 1
[...]
Class name 2
[...]
…

Maxpm
- 24,113
- 33
- 111
- 170
9
votes
1 answer
How to call ambiguous generic function in Swift?
I've defined two generic functions
func job(x: T) {
println("1")
}
func job(x: T) {
println("2")
}
and when I try to call one of them, for example with:
let myInt: Int = 1 // Explicit Int just for clarity of the…

Bartek Chlebek
- 1,665
- 1
- 16
- 23