The problem I see is not about the name of the enum
type in C Language but of the names of the enum
items. In C and C++ (without enum class
) It is as if each item in an enum
definition is equivalent to a [global?] const int
name =
i;
I agree that one can use some form of qualifier on the names of the items so that there is likely no collision with any other constants. The advantage of enum
is the avoidance of magic numbers and providing some level of semantic information about the intended significance.
It is also easy to update an enum
definition and do other things with it. One can do cases on enum items but, unfortunately, not so easily define sets and name-value maps. Don Knuth and Don Woods came up with a clean way of doing that in the Literate Programming version of the game I am busy transposing to Clean C in open-source style. It is all done with run-time “loading” of hash tables and arrays, so you don’t have to depend on knowledge of the “index” of enumeration item values. (This is sort of constructors by-hand in the absence of classes.)
I think I can use Visual Studio refactoring to fix the names of items to incorporate qualification. I have to do that before separating the single file Knuth-Woods version into separate modules for using modern build solutions. If I refactor prematurely into separate files, I will have made a terrible mess for myself .
Thanks for your comment. You’ve helped sharpen my thinking on how to work this when working at the Clean C level.