Worst ideas/features in programming languages?

Timon Gehr timon.gehr at gmx.ch
Thu Jan 6 13:01:07 UTC 2022


On 1/6/22 06:58, Paul Backus wrote:
>>
>> Why is that a surprise? You could similarly do something like:
>>
>> alias S=AliasSeq!(string);
> 
> Perhaps this is a better illustration:
> ...

No, it's the same thing. I understand what you are saying, I just don't 
agree it's important or likely to cause surprises in practice.

>      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
>      }
> 
> It's perfectly logical if you know about opArgs and have the definition 
> of A in front of you, but it's extremely surprising and unintuitive if 
> you don't.

Again, why is that different from the alias case? Furthermore, why would 
you use this feature willy-nilly in the first place without an intention 
to implement tuple semantics? "You can use this feature to write bad 
code" is a weak argument, it applies to every language feature.


More information about the Digitalmars-d mailing list