Worst ideas/features in programming languages?

Walter Bright newshound2 at digitalmars.com
Wed Jan 5 06:33:39 UTC 2022


On 1/3/2022 7:09 PM, Timon Gehr wrote:
> My DIP draft extends "alias this" to allow this (which should work anyway):
> 
> alias Seq(T...)=T;
> struct S{
>      byte b;
>      int c;
>      alias this=Seq!(b,c);
> }
> 
> void func(byte,int);
> 
> func(S());

I confess, this makes me uneasy. `alias this` produced a lot of unintended 
consequences. I'm gunshy of extending it. I'd prefer:

     func(S().tupleof);


> It 
> does have some significant drawbacks, e.g. `foo(int,int)` and `foo((int,int))` 
> would have a different ABI and the second overload can't be called as 
> `foo(1,2);`...

I tried to actively avoid that :-)

> To be very clear, I want this:
> 
> [(1,2),(3,4)].map!((a,b)=>a+b).each!writeln;
> 
> An this is generally what people mean when they talk about "tuples".

I understand. It looks like a worthy goal.


More information about the Digitalmars-d mailing list