godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.3k stars 21.24k forks source link

Style: Purge `.compat.inc` files #99517

Closed Repiteo closed 3 hours ago

Repiteo commented 13 hours ago

I very, very strongly dislike the use of .compat.inc files. They exist as files dedicated to a handful of function implementations that aren't even wholly separated because they have to be initially declared in header files. From where I sit, it makes much more sense to handle these functions in their respective implementation file, as we're already doing in their headers. I don't have any concrete or objective resources to back this up, it's really as simple as me not liking them to the extent that I made a PR entirely out of spite

KoBeWi commented 12 hours ago

These files allow for clearer separation of compatibility code. I'd actually go in opposite direction and do more of that (#89160).

it makes much more sense to handle these functions in their respective implementation file, as we're already doing in their headers.

They are in the headers only because it's the only way.

Repiteo commented 12 hours ago

They are in the headers only because it's the only way.

Ehh, not entirely. We've seen other headers use .inc files to define logic as if they were in headers; the most obvious example being bvh_tree.h. I'd be MUCH more open to the idea of these files if the headers got the same treatment. Hell, you could probably make dedicated #ifdef <HEADER_NAME_H> defines to have that same file handle header and implementation logic

...Shit, I might've talked myself into this

akien-mga commented 6 hours ago

...Shit, I might've talked myself into this

Let me put a blocker here for now. This needs to be discussed with maintainers before doing more significant work there.

This kind of change shouldn't be done on a whim for personal taste reasons. There's a reason why we designed a system with separate files for compat code. You would need to look up that reason before deciding to yank it.

Edit: I dug up through the history for this which wasn't obvious to find. This was designed in https://github.com/godotengine/godot/pull/76577, you'll need to expand some of the resolved discussions to see it.

I'm pretty sure there was more discussion spread across Rocket.chat and some issues, but yeah at this point tracking it down is a bit of investigative journalism work :P

But in short:

See e.g. these examples from this PR:

 scene/animation/animation_player.compat.inc   |  76 ---------
 scene/animation/animation_player.cpp          |  48 +++++-
 scene/gui/popup_menu.compat.inc               |  81 ----------
 scene/gui/popup_menu.cpp                      |  53 +++++-
 servers/rendering/rendering_device.compat.inc | 151 ------------------
 servers/rendering/rendering_device.cpp        | 123 +++++++++++++-

Adding 123 lines of code to rendering_device.cpp that are not relevant for the current workings of this class is just adding more code that developers need to ignore or somehow load in their mental model when working on the class (and this will keep increasing, there are more compat breakages in the pipeline, and some more complex to handle than just a oneliner redirection method).

Repiteo commented 3 hours ago

You know what, that's entirely reasonable. I might not entirely agree, but their reason for existing being laid out makes a lot of things "click". Closing.