Ada has subtypes for such cases: https://en.wikibooks.org/wiki/Ada_Programming/Type_System#Co...
Re:Why Don't People Use Formal Methods?
by Uberphallus on Tuesday January 22, 2019 @07:22AM
(#18967745)
And checks on compile time are quite insightful, Ada tends to know beforehand if you're gonna run out of bounds.
Or, don't split between primitives vs objects.
I think it's a mistake to make thet distinction in many language's design.
For example an integer. In most languages and tools this is a primitive.
But most of the time we need a specific type of integer, for example a positive natural number. You can use a unsigned integer for this but that will include a zero wich we don't want.
So maybe you can use a type/domain object for this in your code, but what about the database field or communication methods?
It all can be done but with a lot of hussle.
I think it would help if we had more primitives that would work in the complete stack.
But then the question is: should ISO 639-2 also be a primitive?