-
-
Notifications
You must be signed in to change notification settings - Fork 99
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
Multiple inheritance (mixins) in gdscript #1093
Comments
Duplicate of #758. |
Imo this is not a duplicate. at least I don’t see how this could solve the problem above. I quickly googled traits, and I got the impression that they are not able to do everything that python mixins can do In this case, should I rename proposal to emphasize that I mean python-like mixins, not traits? |
@me2beats Multiple inheritance will probably never be added to GDScript. A trait system is much more likely to be added in the future. |
Where can I find out the reasons for this decision? |
There have been a few claims here and there that multiple inheritance would be contrary to GDScript's goals of simplicity. Like this part in the documentation: https://docs.godotengine.org/en/latest/getting_started/scripting/gdscript/gdscript_advanced.html#duck-typing For the record, GDScript is being rewritten from scratch for Godot 4.0. |
Describe the project you are working on:
I am developing gdscript plugins that I am going to support for a long time.
I am convinced that code support requires code purity, as well as keeping the code base as small as possible (without enthusiasm of course), in particular adherence to the DRY principle.
Describe the problem or limitation you are having in your project:
Say, I want to have a class A that contains 2 independent code parts:
one part overrides the
add_child
methodthe other part overrides
_to_string
method.and I also notice that I could reuse these code parts separately for other classes.
but I can't do it easily in gdscript
Using composition also can't solve this problem.
Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Multiple inheritance, particularly python like mixins, could elegantly solve this problem
Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
I could have those code parts in 2 different classes (scripts).
and be able to "mixin" them with the main class.
If this enhancement will not be used often, can it be worked around with a few lines of script?:
no unfortunately.
This is not solved by composition or workaround as elegantly as with mixins.
Is there a reason why this should be core and not an add-on in the asset library?:
it should not be implemented as an addon.
Imo it's more logical to have this as a feature of the gdscript language.
The text was updated successfully, but these errors were encountered: