Worst ideas/features in programming languages?
    Paul Backus 
    snarwin at gmail.com
       
    Thu Jan  6 05:58:54 UTC 2022
    
    
  
On Wednesday, 5 January 2022 at 23:56:03 UTC, Timon Gehr wrote:
> On 1/5/22 23:42, Paul Backus wrote:
>> On Wednesday, 5 January 2022 at 07:28:41 UTC, Timon Gehr wrote:
>>>
>>> How about something like opArgs, dealing specifically with 
>>> this case? (i.e., a function call `foo(x)` with a single 
>>> argument is immediately rewritten to `foo(x.opArgs)` if `x` 
>>> has a member `opArgs`, and this rewrite is applied exactly 
>>> once.)
>> 
>> This mechanism seems too powerful to me; for example, one 
>> could write code like the following:
>> 
>> [...]
>
> Why is that a surprise? You could similarly do something like:
>
> alias S=AliasSeq!(string);
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
     }
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.
    
    
More information about the Digitalmars-d
mailing list