Worst ideas/features in programming languages?
Timon Gehr
timon.gehr at gmx.ch
Thu Jan 6 13:18:56 UTC 2022
On 1/6/22 06:58, Paul Backus wrote:
>>
>
> Perhaps this is a better illustration:
>
> struct A {
> B opArgs() { return B(); }
> }
>
> struct B {}
>
> string fun(A) { return "A"; }
> string fun(B) { return "B"; }
>
> void main() {
> assert(fun(A()) == "A"); // fails
> }
BTW, it should work like this:
```d
void foo(string x){} // <- a string, not a tuple
void foo(string x,){} // <- unary tuple
void foo((string,) t){} // <- unary tuple
void foo(string x,int y){} // <- 2-tuple
void foo((string,int) t){} // <- 2-tuple
```
So perhaps your example would not even work that way; unary tuples
shouldn't decay into the underlying type. The concept will need some
fleshing out. Maybe it's indeed too hard to actually retrofit this into
the language...
More information about the Digitalmars-d
mailing list