Named arguments and generic type inference in C# 4.0

前端 未结 3 1520
耶瑟儿~
耶瑟儿~ 2020-12-24 01:33

I had been programming under the assumption that, when calling a method in C# 4.0, supplying names for your arguments would not affect the outcome unless in doing so you wer

3条回答
  •  旧巷少年郎
    2020-12-24 02:12

    Inference is not something that will work at many nested levels in compilation. It is kind of a guess based on arguments supplied. I feel the compiler writers did not consider inferring logic along with named parameter. If you consider abstract syntax tree, Even though the logic is same, but both F(()=>"xyz") And F(f:()=>"xyz") Are different abstract syntax trees from compiler's perspective.

    I feel it's just a rule missed by compiler designer where even the compiler itself is a program with huge set of rules. One rule matches first case but no rule matches second one. It may be conceptually right but compiler is just a program and all rules are human coded.

    Ok, I guess as others have determined, its a bug and should be reported to Microsoft !!

提交回复
热议问题