-
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 interface implementation a.k.a. Traits #16139
Comments
Thank you, believe it or not I did search this beforehand and had little luck, perhaps because the terms are all used a hundred times in different situations. |
This is actually more related to #258. |
This appears to be a dup of #258. |
Let's not forget how this relates to #4586 :) Scala has the |
We are now taking language feature discussion on https://github.com/dotnet/csharplang for C# specific issues, https://github.com/dotnet/vblang for VB-specific features, and https://github.com/dotnet/csharplang for features that affect both languages. Traits are now proposed at dotnet/csharplang#52 and are under active design/development. |
I believe C# could benefit from from a feature similar to traits in Scala, or mixins in other languages. This proposal could be a potential implementation for asks in both #73 or #258. The main difference would be in the implementation.
Benefits
Syntax
Syntax: Overriding default implementation
Goal: Don't introduce new complexity, just reuse "override" here
This example, while contrived demonstrates a scenario where I've chosen to implement one of the two functions in the interface, For the implementation, I've chosen explicitly to use expression bodied methods as the implementor of the functionality.
Side Note: I wonder how much IEquatable code is being copied and pasted between classes in code bases because this feature is missing.
The text was updated successfully, but these errors were encountered: