, and many other languages support ranges, one way to subtly subtype a boundary is a signed integer value which is the value ( From first) to second (last). It is easy to implement such a class in the OF, but I think that supporting the facility can basically allow the compiler to perform additional static testing.
I know that it is impossible to determine that a limit defined in a variabile is not going to run overflow runtime, that is, due to poor input, but I think that can be done. I think about the approach (Eiffel) and Tip # (), which gives more general solutions.
Is there a simple solution that at compile time at least, static out-of-C ++, C # and Java?
Edit : I understand that "ranges" can be used for different categories:
- Iterator
- Enumemeter
- Integer subtype
I will focus on the latter, because the farmers can easily copy over the C * language. I think of a closed set of values, like some music, i.e. a category that grows from 1 to 100. I would like to raise or lower it by the value I would like a compilation error in the case of a static overflow, like something:
volume = rangeInt (0,100); Quantity = 101; // COLLECTION ERROR! Quantity = getIntFromInput (); // possible runtime exception
thanks.
Sub types are really not very useful in practice We do not often allocate fixed length arrays , And there is no reason for the integer of fixed size. Usually where we look at fixed size arrays, they are working as an enumeration, and we have a better (though "heavy") solution.
Subaraz Type also makes type system difficult
(mandatory mention that integer should have arbitrary size in any sensible language.)
Comments
Post a Comment