Skip to content

Conversation

@timothyqiu
Copy link
Member

@timothyqiu timothyqiu commented Jun 5, 2025

Closes godotengine/godot-proposals#9824

Whether a virtual method is required has been marked by #93311. This PR:

  • Makes editor help & online doc show a required qualifier next to virtual if the method is required.
  • Removes the manually added [b]Optional.[/b] and [b]Required.[/b] from the descriptions of related methods.

@timothyqiu timothyqiu requested review from a team as code owners June 5, 2025 03:22
@bruvzg bruvzg added this to the 4.5 milestone Jun 5, 2025
@Mickeon
Copy link
Member

Mickeon commented Jun 5, 2025

If you didn't do it I would have, to be honest.
Although I have a hunch that the "required" qualifier is much more important than the rest, and should be highlighted as such in some way.

AThousandShips
AThousandShips previously approved these changes Jun 5, 2025
Copy link
Member

@AThousandShips AThousandShips left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, and has associated tooltips so should be complete

Copy link
Member

@Mickeon Mickeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like, this is a fine addition, but I still stand by my prior comment. Perhaps it could be formatted in bold in the built-in class reference?

@dalexeev
Copy link
Member

dalexeev commented Jun 5, 2025

I would prefer "abstract", which is a common term for virtual methods with no default implementation. See also:

I wanted to make this a step up from GDScript's abstract methods, since changing the behavior if you didn't implement the required native methods would be a compatibility break. So, looking at it another way, a separate qualifier might make sense too, although it's more confusing and less unified.

@timothyqiu
Copy link
Member Author

I have a hunch that the "required" qualifier is much more important than the rest, and should be highlighted as such in some way.

We don't have abstract methods yet, so currently "required" is a soft requirement, hinting that a minimum implementation should at least overwrite these methods to function properly without any error printed, I think.

image

The editor theme & editor help currently does not have the concept of a bold code font. It could be a dedicated PR if appropriate.

@timothyqiu timothyqiu changed the title Doc: Add "required" qualifier to methods Doc: Add "abstract" qualifier to required virtual methods Jun 5, 2025
@dalexeev
Copy link
Member

dalexeev commented Jun 5, 2025

To be clear: I don't mind the way you did it initially. The abstract qualifier implies stronger requirements and some compatibility breakage. For example, a GDScript class extending EditorHelp without implementing the _run() method and not marked as abstract should produce a compile-time error.

Another difference is that you can't instantiate an abstract GDScript class at all, while you can instantiate EditorScript without an attached script (the difference between abstract and virtual classes in Godot terms).

Considering that even custom abstract GDScript methods are highly unlikely to make it into 4.5, unifying native abstract methods in 4.5 is out of the question. I think it would be acceptable to introduce the required qualifier and then replace it with abstract. If it only concerns Editor Help, not XML files.

@AThousandShips AThousandShips self-requested a review June 5, 2025 10:00
@AThousandShips AThousandShips dismissed their stale review June 5, 2025 10:00

Major changes

@timothyqiu
Copy link
Member Author

OK, reverted to the "required" version.

It sounds like abstract methods are meant to be implemented as a GDScript functionality rather than core functionality, but we'll see about that later.

@timothyqiu timothyqiu changed the title Doc: Add "abstract" qualifier to required virtual methods Doc: Add "required" qualifier to methods Jun 5, 2025
Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me. I suggest being a bit more explicit in the message, other suggestions welcome.

Copy link
Contributor

@dsnopek dsnopek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is a really great idea!

@akien-mga akien-mga merged commit b6f04cb into godotengine:master Jun 5, 2025
20 checks passed
@akien-mga
Copy link
Member

Thanks!

@timothyqiu timothyqiu deleted the pure-virtual branch June 6, 2025 01:01
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.

Mark some virtual methods as required in class reference XML

7 participants