-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Add a C++ usage guidelines page #3668
Add a C++ usage guidelines page #3668
Conversation
Lambdas | ||
^^^^^^^ | ||
|
||
The use of lambdas is generally not allowed, unless they can greatly help with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote the part about lambdas this way because we have a few instances of lambdas in the current editor code. These could be rewritten into macros, but it's not really convenient.
We also have a handful of auto
keywords in use, but that can be changed more easily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say:
Lambdas should be used conservatively when they make code effectively faster or simpler, and do not impede readability.
b333e3a
to
44265e0
Compare
44265e0
to
3dad486
Compare
Can we add a short section on the appropriate usage of switch cases? I'm bringing it up because of its inconsistent use throughout the code base, specifically on Examples:
|
@FlashDaggerX Thinking about it, I think we should always use |
Could someone explain the reasoning behind disallowing for-range-loops to me? Plus I would argue that the readability and ease of use make them beneficial for "beginner contributors (who may not be |
3dad486
to
bfa2374
Compare
What's the PR's status? What's missing? Is there a way we can review and merge what's available and consider extending it later? |
@NathanLovato I think this is good to merge as-is, but it would be good to get @akien-mga's approval (especially the part about lambdas). |
7a7b899
to
b9dfa42
Compare
9c72241
to
9c4954c
Compare
9c4954c
to
75c9fd5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a read, and the significant points about autos, STL, and lambdas have been commonly agreed upon by the contributor team.
This page describes C++ features that are used and allowed in Godot's codebase. It's based on community consensus over the last months, as Godot recently moved to C++17 in the `master` branch.
75c9fd5
to
84ac4ac
Compare
Should this page be pushed to We could maintain a dedicated page for |
I think that notable differences and general code compatibility warning should be a part of the page anyway. People still support 3.x actively, so we should mention the caveats in the docs. Then it wouldn't matter in which version we store the page, as it would be applicable to the development in general. |
This page describes C++ features that are used and allowed in Godot's codebase. It's based on community consensus over the last months, as Godot recently moved to C++17 in the
master
branch.I've probably missed many things, so please leave comments. That said, the C++ style we expect is now (mostly) set in stone, so most disallowed features written here are not negotiable (such as
auto
). Please keep the discussion on-topic 🙂I know @hpvb intended to write this page at first, but I decided to do it to help speed up the process.
This closes godotengine/godot#9694.