Repository navigation
RFC #24: Struct inheritance #31
ProCode-Software
started this conversation in
RFCs
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.
super()constructor that must be called. The first idea that comes to mind is copying fields from other types, and if there is a field collision between 2 inherited types, it must be explicitly overriden.There are a few concerns with this:
MyStructinheritsAandB, but when we override a field's type,MyStructcannot be converted to either type. This is misleading.hasXonMyStructbecause the methods on both inherited types reference the fieldxof a different type. With these rules, it may not be clear what methodsMyStructinherits (finding out may require looking in the bodies of several methods in the inherited types, which may also have their own inherited types).type X { x: Int, y: Int = self.x }. A type override could remove other fields.I would like some ideas on how inheritance can be implemented, such as Go-style embedding.
All reactions