-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Partial type inference #5153
Comments
What happens if you have both I would prefer something like |
Last suggestion is a duplicate of #2319. |
I think a solution that allow you to partially constrain type resolution would be a nice addition. Like:
|
Yes. I'm running into this issue a lot too. It's very inconvenient to duplicate compilation information which can be infered. That and #2319 would be very convenient. |
We are now taking language feature discussion on https:/dotnet/csharplang for C# specific issues, https:/dotnet/vblang for VB-specific features, and https:/dotnet/csharplang for features that affect both languages. See also #18002 for a general discussion of closing and/or moving language issues out of this repo. |
Hello!
I often run into situations where I would like to partially specify the types, but the rest can be inferred from the parameters. For example, when building a "Validation Rule" system, where validation rules are encapsulated as composable objects:
I can't think of any reasons (granted, I'm not as well placed to think of problems as some other people here might be) that it wouldn't be able to infer the second type, as follows:
As it stands now, I usually use an intermediate object or function which splits the type parameters up, but this gets awkward.
Similarly, it would be great if type inference was available on constructors!
would translate to
The text was updated successfully, but these errors were encountered: