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

Create custom base classes #403

Closed
coder137 opened this issue Sep 10, 2023 · 3 comments
Closed

Create custom base classes #403

coder137 opened this issue Sep 10, 2023 · 3 comments
Labels
question Not a problem with the library, but a question regarding usage.

Comments

@coder137
Copy link

Currently we use existing base classes that are exposed via GDExtension (for example Node and NodeVirtual).

What would it take to create a custom base class in rust?

@lilizoey lilizoey added the question Not a problem with the library, but a question regarding usage. label Sep 10, 2023
@lilizoey
Copy link
Member

This would open up a whole can of worms with regard to inheritance in rust. Currently we can avoid a lot of the issues that inheritance brings from a programming language design perspective since we statically know all the classes you can inherit from. But things like variance and type safety in the presence of arbitrary inheritance could be really difficult to sort out.

#334 is a proposal for a more restricted kind of inheritance. Where we allow the creation of a single abstract base class for an enum. Something like that is more feasible, and even then the discussion there shows how many issues there are to sort out.

@coder137
Copy link
Author

That makes sense, Will look at #334 and the discussion there.

Please close the issue if this feature is not going to be planned for this project.

@Bromeon
Copy link
Member

Bromeon commented Sep 10, 2023

At the moment, it's not planned. The benefits are relatively small compared to all the issues it brings, and inheritance is not an abstraction mechanism you would choose within Rust itself. Traits and composition should be preferred when possible.

@Bromeon Bromeon closed this as not planned Won't fix, can't repro, duplicate, stale Sep 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Not a problem with the library, but a question regarding usage.
Projects
None yet
Development

No branches or pull requests

3 participants