Jump to content

Ada Programming/Delimiters/..

From Wikibooks, open books for an open world

Ada. Time-tested, safe and secure.
Ada. Time-tested, safe and secure.

The delimiter .. is used to specify ranges in any scalar type.

For example:

  • In numeric type definitions:
type Count is range 0 .. Max_Count;
subtype Week_Day is Day_Name range Monday .. Friday;
Vector_A : Vector (0 .. 31);
exit when X in Y .. Y + Epsilon;
for Day in Day_Name range Monday .. Thursday loop
   -- ...
end loop;
Vector_A (Vector_A'First .. Vector_A'First + Vector_B'Length - 1) := Vector_B;

Usage notes

[edit | edit source]

When a whole type range will be specified, it is better to use the Range attribute.

For example, instead of using:

for Day in range Day_Name'First .. Day_Name'Last loop
   -- ...
end loop;

it is better to use:

for Day in Day_Name'Range loop
   -- ...
end loop;

See also

[edit | edit source]

Wikibook

[edit | edit source]

Ada Reference Manual

[edit | edit source]