Anonymous user
Define a primitive data type: Difference between revisions
m
Fixed lang tags.
Underscore (talk | contribs) (→{{header|Perl 6}}: Fixed (Whatever doesn't play nicely with chained comparisons, at least at the moment).) |
m (Fixed lang tags.) |
||
Line 3:
=={{header|Ada}}==
The compiler identifies the range of valid values from the range specification ''1..10'' and automatically builds in bounds checking where it is needed. The compiler is smart enough to omit bounds checking when it is not needed.
The compiler will omit bounds checking for the assignment of A to B above because both values are of My_Type. A cannot hold a value outside the range of 1..10, therefore the assignment cannot produce an out of bounds result.
Line 16:
{{works with|ALGOL 68G|Any - tested with release mk15-0.8b.fc9.i386}}
<!-- Note: I cannot use
# assume max int <= ABS - max negative int #
INT max bounded = ( LENG max int * max int > long max int | ENTIER sqrt(max int) | max int );
Line 656:
{{works with|Rakudo|#22 "Thousand Oaks"}}
<lang
my OneToTen $n = 5;
Line 663:
<code>{ 1 <= $^n <= 10 }(11)</code> returns a false value, so the second assignment throws an exception. You can use any unary function in place of <code>{ 1 <= $^n <= 10 }</code>, so this, for example, is also legal:
<lang
=={{header|Python}}==
Line 688:
>>> type(x)
<class '__main__.num'>
>>>
=={{header|Ruby}}==
|