Autoincrement on number and bigint #13
Replies: 3 comments 7 replies
-
Absolutely not, for the reasons you mentioned. |
Beta Was this translation helpful? Give feedback.
-
Is it possible to leave that to decorator? @autoinc enum E1 of BigInt { X, Y, Z } |
Beta Was this translation helpful? Give feedback.
-
Python enums support auto-numbering via a static |
Beta Was this translation helpful? Give feedback.
-
In many languages
enum
can auto-increment its value:X
,Y
,Z
equals0
,1
and2
.Problem
This is very useful in the development but this feature actually is a refactoring hazard and a foot gun.
When you add a new member in the middle, all following enum member value changes, that might cause API surface changes accidentally, break the application, or even introduce security bugs.
Flow.js does not allow autoincrement on number enums. All number enums must have an initializer to specify their value to prevent this foot gun.
Should we support autoincrement?
Beta Was this translation helpful? Give feedback.
All reactions