Retroactive interface conformance #43
KnightBreaker
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
It would be great to look at other languages strengths and potentially mimic those in verse.
Right now we can conform a class of our control to an interface and that‘s it. But other languages can do it retroactively. This means that you can extend other classes which you might not own with your own interfaces.
Unlike current extensions which only provide a single non-referencible method, an extension like this would provide everything interfaces already offer, as long as the conformance conditions can be met.
Bikeshedding syntax:
The
extend ... { ... }introduces a full new scope where the developer can provide implementation for multiple methods and computed properties. It doesn't have to be limited to interface (trait?) conformance only.The hypothetical
with my_interfaceis the actual retroactive conformance, where on the right hand side there could be an optionalwhereclause for conditional conformance.To give a quick hypothetical example:
This feature is inspired by Swift.
Beta Was this translation helpful? Give feedback.
All reactions