Extension interfaces or implicit implementation of interfaces at compile-time. #4228
-
I really like the principle of Interfaces, that I don't care what it is, just that it contains what I need. The problem I often face with interfaces however is not being able to utilize them for existing API's, I have to hope that the API already implements the Interface or I'm out of luck. It would be immensely useful if I could extend an existing class by implementing a fitting Interface for it [💡] However even though it would be a great fix it would get repetitive if you're gonna store many different classes based on an Interface none of them have implement yet. It would be much more useful if interfaces were implemented implicitly by the compiler. That means every time you try to cast a class to an Interface that already fits, the compiler would allow it and implement the interface to the given class at compile time. [💡] I know almost nothing about creating languages nor compilers so I appreciate all info into why this, or anything similar, isn't already in the language, what the drawbacks are, etc. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Check out these discussions: There's a lot there, but the gist is that the team is interested in stuff in this space and how they can be used with generics so that existing types can be made to conform to their constraints. |
Beta Was this translation helpful? Give feedback.
Check out these discussions:
#1711
#164
There's a lot there, but the gist is that the team is interested in stuff in this space and how they can be used with generics so that existing types can be made to conform to their constraints.