Allow "eliding" the typing of all generic arguments #7596
-
Generic argument inference is great, but it still has some sharp edges. Namely, the ability to elide specification of the entire generic qualifier if (even just) one type is not in the parameter list. For the current state of C#, say I have some function that takes // function contents are irrelevant
public T OneArity<T>(T input) => ...;
public TOutput TwoArity<TInput>(TInput input) => ...;
// can elide the one-arity call, but can't for the two-arity call
int one = OneArity(42); // or OneArity<int>(42)
int two = TwoArity<double, int>(42.0); ProposalI propose the "sink" keyword
Specification ChangeThe C# specification (section 8.4.2) would be changed as follows: type_argument_list
: '<' type_arguments '>'
;
type_arguments
: type_argument (',' type_argument)*
;
type_argument
: type
+ : '_'
; Backwards CompatibilityThe only possible hiccup this proposal could cause is for users who have a type called |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Duplicate of #1349, which @TomatorCZ is actively working on specing in #7582. |
Beta Was this translation helpful? Give feedback.
Duplicate of #1349, which @TomatorCZ is actively working on specing in #7582.