Skip to content
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

Inheritance #117

Open
awesomekling opened this issue May 19, 2022 · 5 comments
Open

Inheritance #117

awesomekling opened this issue May 19, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@awesomekling
Copy link
Contributor

Classes and structs should be allowed to inherit from other classes and structs respectively.

class Animal {
}

class CatDog: Animal {
}

struct Sport {
}

struct Football: Sport {
}

Note that a struct can't inherit from a class and vice versa, as that would break the reference counting ownership model.

@awesomekling awesomekling added the enhancement New feature or request label May 19, 2022
@linusg
Copy link
Member

linusg commented May 19, 2022

What should syntax for multiple inheritance look like?

@awesomekling
Copy link
Contributor Author

What should syntax for multiple inheritance look like?

Good question! I would like to explore if we can avoid multiple inheritance and instead express interfaces/protocols/traits using a separate mechanism. :^)

@iKlsR
Copy link

iKlsR commented May 20, 2022

I know it's very very early but I hope to see soon some proper light RFCs so some thought goes into these and a public roadmap. Very interested how this will evolve.

@nasloj
Copy link

nasloj commented May 23, 2022

Great input!

@erf
Copy link

erf commented May 23, 2022

Dart uses mixins, a concept which lets you add features to a class without using multiple inheritance like explained in this article.

If you are allowing inheritance, please consider adding super calls in the constructor and avoid having to call the super constructor explicitly, as was just announced in Dart 2.17 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants