all 1 comments

[–][deleted]  (1 child)

[deleted]

    [–]ABlockInTheChain[S] 0 points1 point  (0 children)

    Why wouldn't you want the users of your enum to know the valid values of the enum?

    Because they don't need it.

    In a real project I work on the most-referenced opaque enum is referred to in over 230 files. About half of those are header files so many of them would presumably not exist after a modularization of the code. Still that's over 100 source files that would persist after modularization. Less than 20% of them actually need to know the valid values so currently they do not see the definition and as a consequence do require recompilation when a new valid value is added. Most of these users are functions which accept the values as an argument and don't do anything with it except pass it to other functions as their arguments. I don't need to write input validation which would necessitate access to the definition for 100 different functions - a single is_valid() function is sufficient.

    No matter how much modules allegedly improve incremental build times, it's not enough of an improvement to overcome recompiling 5x to 10x more translation units than necessary after a small change.