Worst ideas/features in programming languages?
Timon Gehr
timon.gehr at gmx.ch
Tue Jan 4 02:06:53 UTC 2022
On 03.01.22 10:27, Walter Bright wrote:
> On 1/2/2022 11:42 PM, Timon Gehr wrote:
>> And there is also this:
>>
>> void foo(T...)(T args){}
>>
>> int[2] x;
>>
>> foo(x); // foo!(int[2]) and foo!(int,int) would now need to be the same
>
> With such implicit conversions, the language would just descend into
> chaos. So no :-)
It's not an implicit conversion. I am mostly trying to figure out what
constitutes "unification" for you. (In the programming languages I
built, `int×int` and `int^2` are literally the same type, there is
subtyping, but all actual type conversions are explicit.)
Personally, the single thing I care most about in terms of "unification"
is that this works:
void foo(int a,int b){}
(int,int) t;
foo(t); // ok, function expects (int,int), and (int,int) was given
But *not* this:
void foo((int,int) a,int b){}
(int,int,int) t;
foo(t); // error, function expects ((int,int),int), not (int,int,int)
I do not care much about `is((int,int)==int[2])`, but when you say you
want to unify tuples and static arrays, that's what I think of.
More information about the Digitalmars-d
mailing list