|
|
Line 952: |
Line 952: |
|
|
|
|
|
end program BoundedTest</lang> |
|
end program BoundedTest</lang> |
|
|
|
|
⚫ |
=={{header|Free Pascal}}== |
|
⚫ |
''See [[#Pascal|Pascal]]'' |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
n := n + 10; // will yield a run-time error |
|
⚫ |
|
|
⚫ |
The FPC (Free Pascal compiler) by default does ''not generate'' range checks. |
|
⚫ |
Assigning a value out of range is possible. |
|
⚫ |
Only constant expressions, i. e. expressions that can be evaluated entirely during compile-time, are not accepted, if they are out of range. |
|
|
|
|
⚫ |
The compiler directive <tt>{$rangeChecks on}</tt> will enable insertion of range checks. |
|
⚫ |
If an out of range assignment is attempted, a run-time error occurs. |
|
|
|
|
⚫ |
Note, in <tt>{$mode Delphi}</tt> range checks are only switchable at procedural level, not on a per expression-basis. |
|
|
|
|
|
=={{header|FreeBASIC}}== |
|
=={{header|FreeBASIC}}== |
Line 999: |
Line 1,019: |
|
i = 10 j = 3 k = 4 j + 6 = 9 j + k = 7 |
|
i = 10 j = 3 k = 4 j + 6 = 9 j + k = 7 |
|
</pre> |
|
</pre> |
|
|
|
⚫ |
=={{header|Free Pascal}}== |
|
⚫ |
''See [[#Pascal|Pascal]]'' |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
n := n + 10; // will yield a run-time error |
|
⚫ |
|
|
⚫ |
The FPC (Free Pascal compiler) by default does ''not generate'' range checks. |
|
⚫ |
Assigning a value out of range is possible. |
|
⚫ |
Only constant expressions, i. e. expressions that can be evaluated entirely during compile-time, are not accepted, if they are out of range. |
|
|
|
|
⚫ |
The compiler directive <tt>{$rangeChecks on}</tt> will enable insertion of range checks. |
|
⚫ |
If an out of range assignment is attempted, a run-time error occurs. |
|
|
|
|
⚫ |
Note, in <tt>{$mode Delphi}</tt> range checks are only switchable at procedural level, not on a per expression-basis. |
|
|
|
|
|
|
=={{header|Go}}== |
|
=={{header|Go}}== |
Line 1,831: |
Line 1,831: |
|
$t = 'xyzzy'; |
|
$t = 'xyzzy'; |
|
# dies, too small. string is 0 interpreted numerically</lang> |
|
# dies, too small. string is 0 interpreted numerically</lang> |
|
|
|
⚫ |
|
|
|
|
|
⚫ |
<lang perl6>subset OneToTen of Int where 1..10; |
|
|
|
|
⚫ |
|
|
⚫ |
|
|
|
|
|
⚫ |
Here the result 11 fails to smartmatch against the range <code>1..10</code>, so the second assignment throws an exception. You may use any valid smartmatch predicate within a <code>where</code> clause, so the following one-argument closure is also legal: |
|
|
|
|
⚫ |
<lang perl6>subset Prime of Int where -> $n { $n > 1 and so $n %% none 2 .. $n.sqrt }</lang> |
|
|
|
|
|
|
=={{header|Phix}}== |
|
=={{header|Phix}}== |
Line 1,954: |
Line 1,943: |
|
(define y 18) |
|
(define y 18) |
|
</lang> |
|
</lang> |
|
|
|
|
⚫ |
|
|
|
(formerly Perl 6) |
|
|
|
|
⚫ |
<lang perl6>subset OneToTen of Int where 1..10; |
|
|
|
|
⚫ |
|
|
⚫ |
|
|
|
|
|
⚫ |
Here the result 11 fails to smartmatch against the range <code>1..10</code>, so the second assignment throws an exception. You may use any valid smartmatch predicate within a <code>where</code> clause, so the following one-argument closure is also legal: |
|
|
|
|
⚫ |
<lang perl6>subset Prime of Int where -> $n { $n > 1 and so $n %% none 2 .. $n.sqrt }</lang> |
|
|
|
|
|
=={{header|Retro}}== |
|
=={{header|Retro}}== |
Line 2,291: |
Line 2,292: |
|
5 |
|
5 |
|
value out of bounds |
|
value out of bounds |
|
5</pre> |
|
5</pre> |
|
|
|
|
|
=={{header|Ursala}}== |
|
=={{header|Ursala}}== |