4 ms·
> Unfortunately I am not aware of any programming language that either allows the use of all 3 kinds of types or at least uses appropriate names for the availab
by Jtsummers 5y ago
> Unfortunately I am not aware of any programming language that either allows the use of all 3 kinds of types or at least uses appropriate names for the available types.
Ada. You can specify your integer type range (not just integers, but sticking with that here):
subtype Celsius is Integer range -273 .. 1000; -- permits implicit, but range checked, assignment with Integer types and other subtypes of Integer like Natural or Positive
type Celsius is range -273 .. 1000; -- no implicit conversion
type Byte is mod 2**8; -- permits overflow, 255+2 = 1
type Non_Modular_Byte is range 0..(2**8 - 1); -- No overflow, 255 + 2 => Exception
https://learn.adacore.com/courses/intro-to-ada/chapters/strongly_typed_language.html# https://learn.adacore.com/courses/intro-to-ada/chapters/stro...
- adrian_b 5y agoYou are right. Ada had interval types since the beginning (1979), but I had forgotten that modular integer types have been added to Ada in the 1995 Ada standard. So yes, Ada is probably the only one that got this right.