Ada Programming/Delimiters/..
The delimiter .. is used to specify ranges in any scalar type.
For example:
- In numeric type definitions:
type
Countis
range
0 .. Max_Count;
- In subtype definitions:
subtype
Week_Dayis
Day_Namerange
Monday .. Friday;
- In variable declarations:
Vector_A : Vector (0 .. 31);
- In membership tests:
exit
when
Xin
Y .. Y + Epsilon;
- In for loops:
for
Dayin
Day_Namerange
Monday .. Thursdayloop
-- ...end
loop
;
- In arrays:
Vector_A (Vector_A'First .. Vector_A'First + Vector_B'Length - 1) := Vector_B;
Usage notes
editWhen a whole type range will be specified, it is better to use the Range attribute.
For example, instead of using:
for
Dayin
range
Day_Name'First .. Day_Name'Lastloop
-- ...end
loop
;
it is better to use:
for
Dayin
Day_Name'Rangeloop
-- ...end
loop
;