Describe the project you are working on:
Nuclear Reactor control room simulation
Describe the problem or limitation you are having in your project:
I am unable to override some functionality of base classes in child classes.
Describe the feature / enhancement and how it helps to overcome the problem or limitation:
If I have a class A, that overrides a built in function, such as _input, and then I have a class B that inherits from class A. And I want class B to override, and replace the functionality of class A's _input method, it is currently impossible to do so.
Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
Calling of super methods should always be explicit. This is more inline with most other programming languages, so it will be easier for new comers to pick up.
It would work like it does today for user defined methods:
func _input(event):
._input(event) # Explicitly calling the parent's implementation
Here you can choose to call the parent's method, or not. It is not enforced.
Especially because the current behavior of automatically calling the parent's implementation is only for built in methods, it's very confusing to new users of GDScript.
It's also very limiting, as it's currently impossible to truly override a base classes behavior for built in methods.
If this enhancement will not be used often, can it be worked around with a few lines of script?:
It's impossible to work around this implementation at the moment.
Is there a reason why this should be core and not an add-on in the asset library?:
It's a fundamental behavior of GDScript, it can not be modified in any way that I'm aware of other than by changing GDScript it's self.
There could be a warning when methods from base classes aren't called form derived classes.
So people don't forget to call them. That's the reason for current behaviour.
In case not calling those methods is intended warning can be ignored with comment.
Pretty sure there has been extensive discussion on this already, can't find links atm though
Note
Default functions like _init, and most notifications such as _enter_tree, _exit_tree, _process, _physics_process, etc. are called in all parent classes automatically. There is no need to call them explicitly when overloading them.
I think it would make sense to do the same for _input.
I will say that this behavior can sometimes be annoying if you don't want the parent function to get called. I don't know if there is a workaround for that.
There's a workaround for your own code only - putting implementation in seperate method, like:
func _exit_tree():
_exit_tree_impl()
and overriding that method.
If you override something that does not start with a "_", than there is no guarantee that you can recover the default behavior. I wanted to add extra behavior to the "clear" method of a list, I managed to make it "unclearable". The parent method was never called.
This was implemented in https://github.com/godotengine/godot/pull/40670.
Most helpful comment
There's a workaround for your own code only - putting implementation in seperate method, like:
and overriding that method.