Does any programming language support defining constraints on primitive data types?
问题 Last night I was thining that programming languages can have a feature in which we should be able to constraints the values assigned to primitive data types. For example I should be able to say my variable of type int can only have value between 0 and 100 int<0, 100> progress; This would then act as a normal integer in all scenarios except the fact that you won't be able to specify values out of the range defined in constraint. The compiler will not compile the code progress=200 . This