-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[RFC] Enum members style guide #8984
Comments
Let's also vote to see trends.
|
What about |
PascalCase IMO is nicer for the eyes but in the case of abbreviations SCREAM_CASE is more readable: |
For me, it depends on the context. If I'm creating an enum for game commands for a gameserver, I like it to all be uppercase. If I'm creating an enum for Colors or Settings, I prefer PascalCase. |
Duplicate of #7270. I would like to continue the discussion there. |
Oh, I searched "enum style guide" or similar but couldn't find that other issue. Thanks! I'll close this. But noting that PascalCase was voted unanimously, so I think we should go with that. |
I think it's time we decide on what we prefer when naming enum members. As usual, the only requirement is that they start with an uppercase letter. But in the standard library we should be consistent.
Two options:
I prefer PascalCase. The reason is that, even though enum members can be seen as constants, general constants can hold arbitrary types, but enum members only integers. So if you see
Foo::SCREEM_CASE
you will probably think it's some cached value, or a singleton instance. But if you seeFoo::Bar
being assigned to something, or compared against, you will probably think it's an enum member. (It could be a type too, but it's less common to move and compare types around.)Also, I think this looks nicer (all of this is subjective, of course):
But I'd like to know your opinion.
If we agree on a style, we should apply it throughout the standard library, and write about it in the style guide.
The text was updated successfully, but these errors were encountered: