Skip to content

Add a note about _notification() being multilevel #107564

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

Merged
merged 1 commit into from
Jun 18, 2025

Conversation

KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Jun 15, 2025

No description provided.

@KoBeWi KoBeWi added this to the 4.5 milestone Jun 15, 2025
@KoBeWi KoBeWi requested a review from a team as a code owner June 15, 2025 16:37
@Mickeon
Copy link
Member

Mickeon commented Jun 15, 2025

It's not the only one, is it?

Also, this information feels more pertinent to mention in detail in notification instead (and it is), as it explicitly describes how that method works. But it is true that this virtual method is the odd one out, so a shorter note is due.

@Mickeon Mickeon modified the milestones: 4.5, 4.x Jun 15, 2025
@KoBeWi
Copy link
Member Author

KoBeWi commented Jun 15, 2025

It's not the only one, is it?

I don't know any other method like that. Even _init() isn't multilevel.

Also, this information feels more pertinent to mention in detail in notification instead

To me this odd behavior is useful, because you can override this method without worrying that some extending script will replace its behavior, which gave me idea to add the note. Maybe _notification() could be linked in some other methods, like _ready() etc.

@Mickeon
Copy link
Member

Mickeon commented Jun 15, 2025

Not denying the usefulness of this behavior at all. In fact I know someone that used this to explicitly avoid having to write super() every time.
But I am not convinced a note is the right place to provide a example use case. In the current PR, it's somewhat hard to understand and envision. At the same time, providing a more meaningful example may be too much.

Rather, it should probably just mention that this behaviour exists and it's an exception.

@KoBeWi KoBeWi force-pushed the super_notifications branch from 39ddd3f to c63adb1 Compare June 15, 2025 20:07
@Mickeon Mickeon modified the milestones: 4.x, 4.5 Jun 15, 2025
@KoBeWi KoBeWi force-pushed the super_notifications branch from c63adb1 to a96c702 Compare June 15, 2025 20:55
@KoBeWi
Copy link
Member Author

KoBeWi commented Jun 15, 2025

I don't know any other method like that.

I just remembered that the property methods are multilevel in C++. I tested them and _get_property_list(), _property_get_revert(), _get() (and probably _set()) are also multilevel in scripts. _validate_property() and _property_can_revert() are not (bug?).

Should they get a similar note? I wonder if we could mark these methods as multilevel, similar to virtual, const etc.

@Mickeon
Copy link
Member

Mickeon commented Jun 15, 2025

Should they get a similar note?

Probably, yeah. The note itself could be made more generic for the sake of maintainability.

I wonder if we could mark these methods as multilevel, similar to virtual, const etc.

I think a special qualifier would need extra scrutiny as that would require a new method flag (unlike #107130).

_validate_property() and _property_can_revert() are not (bug?).

I swear this has been discussed in the past, but I can't find an issue. Something about how some methods are still "multilevel" despite the transition to Godot 4.0, and how it can't be changed now for fear of compatibility breakage.

@KoBeWi
Copy link
Member Author

KoBeWi commented Jun 15, 2025

Probably, yeah. The note itself could be made more generic for the sake of maintainability.

Something like

[b]Note:[/b] Unlike most virtual methods, this method is called automatically for every extended script. This means you should not call the base implementation via [code]super[/code] in GDScript or its equivalents in other languages.

?

I think a special qualifier would need extra scrutiny as that would require a new method flag

Not really, it could be added manually, like deprecated flags. I know it's not very maintainable, but we have very few such methods and I think we didn't add one since 3.0, if not longer.
EDIT:
Well, _property_get/can_revert() has been multilevel for 2 years actually. That's still quite long though.

@Mickeon
Copy link
Member

Mickeon commented Jun 16, 2025

This PR is good as is, but yeah, this oddity should be mentioned in those respective methods. Maybe asking @vnen for details later?

Only personal gripe is that with the current wording it may be implied that only super() is wrong, but calling the parent method directly (super._notification()) is fine, but... eh.

@KoBeWi
Copy link
Member Author

KoBeWi commented Jun 16, 2025

calling the parent method directly (super._notification()) is fine

That still involves super.

@KoBeWi KoBeWi force-pushed the super_notifications branch from a96c702 to b103f2d Compare June 16, 2025 20:26
@Repiteo Repiteo merged commit 82879db into godotengine:master Jun 18, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Jun 18, 2025

Thanks!

@KoBeWi KoBeWi deleted the super_notifications branch June 19, 2025 01:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants