Re:The type system is a programmer's best friend
by mostlylurks on Saturday November 05, 2022 @03:41PM
(#33484854)
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.
[ Parent
| on HN ]
There are no comments on this comment yet.