4 ms·
Restricting the space of possible values is only one of the possible advantages of declaring a dedicated type for something. Even if it is not possible to restr
by mostlylurks 4y ago
Restricting the space of possible values is only one of the possible advantages of declaring a dedicated type for something. Even if it is not possible to restrict the space of possible values (e.g. with names, which can't realistically be restricted to any smaller subset than all possible strings), there are other advantages to having a dedicated type, such as preventing the user of the type from putting a value of that type into somewhere it doesn't belong, which is a very realistic scenario in stringly typed codebases, especially where there are similar but different sets of values, all stringly typed.