5. Embedded QUEL for Ada : Ada Variables and Data Types : Variable and Type Declarations : The Range Constraint
 
Share this page                  
The Range Constraint
The syntax of the range constraint is:
range lower_bound .. upper_bound
In a variable declaration, its syntax is:
identifiertype_name range lower_bound .. upper_bound;
Syntax Notes:
1. Even if a range constraint is not allowed by Ada, it will be accepted by EQUEL. For example, both of the following range constraints are accepted, although the second is illegal in Ada because the string type is not a discrete scalar type:
## digit: Integer range 0..9;
## chars: String range 'a'..'z';
2. The two bounds, lower_bound and upper_bound, must be integer literals, floating-point literals, character literals, or identifiers. Other expressions are not accepted.
3. The bounds are not checked for compatibility with the type_name or with each other. For example, the following three range constraints are accepted, even though only the first is legal Ada:
## byte: Integer range -128..127;
## word: Integer range 1.0..30000.0;
                                 -- Incompatible with type name
## long: Integer range 1..'z';   -- Incompatible  with each other