Policy for style guide: document use of 'e' prefixed enums in C/C++ #98553
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
6 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#98553
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Currently most typedef'd
enums
use ane
prefix, although this isn't mentioned in the code style guide.As this isn't noted as a convention it's not clear if/when they should be used if it's reasonable to request them in code-review for example.
I'd propose to include this as part of Blender code-style https://wiki.blender.org/wiki/Source/Code_Style - mainly because its following what's already being done (for the most-part), and it can be a useful hint.
When used, it's obvious the name is an
enum
type which are often passed and copied by value and don't need to be declaredconst
in the header for e.g. Where as all other types we normally pass by pointer or reference and declareconst
where possible.From a quick search in
source/
:typedef enum e[A-Z]
+^enum e[A-Z]
-> 817.typedef enum [A-Z]
+^enum [A-Z]
-> 185.This misses some indented declarations but I don't think it makes a big difference.
Added subscriber: @ideasman42
Policy for style guide: use of 'e' prefixed enumsto Policy for style guide: use of 'e' prefixed enums in C/C++Policy for style guide: use of 'e' prefixed enums in C/C++to Policy for style guide: document use of 'e' prefixed enums in C/C++Added subscriber: @HooglyBoogly
Personally I would prefer not so use the
e
prefix for enums, for a few reasons:Type
,Mode
,Flag
etc. in the enum name.For the pass-by-value/const things meantioned in the task, I'm not sure this is much different from other custom types that we also pass by value (
Span
,IndexMask
, etc.)Avoiding enum names that look like struct names makes sense, but personally I don't think this is the best way to do it, and I could see it even making enum names worse.
It doesn't change much, but since
typedef
isn't usually used in C++, I think the searches above misses some examples:enum [A-Z]
-> 188enum class [A-Z]
-> 47Added subscriber: @Sergey
Something we've been talking with Campbell in the blender chat. I share the thoughts with Hans here.
To not repeat what is already mentioned, the gist would be: to me the important part is to make the "meaningful" part of the type name clear. Using
Flag
/Type
whenever the enum is a flag or a type of something I find to be more important.Added subscriber: @mont29
Not really convinced here, don't really see the added value to that rule, not a big fan of adding type hints in names in general... and would rather avoid yet another giant cleanup messing up with tens of header files.
So no hard no from me, but a 'would rather not' ;)
Added subscriber: @JacquesLucke
Generally agree with Hans, Sergey and Bastien here. Don't have another argument to add.
Added subscriber: @dr.sybren
Same here, I agree with Hans, Sergey, and Bastien. For me, personally, these enum-related things are much more important for understandability of the code:
short
andint
as this-should-be-an-enum-type in DNA, so that it's clear which enum is used (this is sometimes already there, but also sometimes not).int
andshort
for enum values in non-DNA code should be forbidden.IMO if you need an
e
prefix for an enum, it's a sign that the declaration is too far from the use, and that the code is likely getting too complex. That's not a problem to be solved with a prefix.PS: the above is not intended to change the scope of this patch. Just to elaborate a bit on my vision on the use of enums in our code.
As the replies here prefer not to use the
e
prefix I've created a counter proposal #99080 (Policy for style guide: document enum suffix use for C/C++).