Options: Use Forum View Use Proportional Font Show Text Part by Default Show All Mail Headers Message: [<< First] [< Prev] [Next >] [Last >>] Topic: [<< First] [< Prev] [Next >] [Last >>] Author: [<< First] [< Prev] [Next >] [Last >>]

```At 2003-07-11 21:55 +0100 Friday, Nick Roberts wrote:
>At 2003-07-08 11:14 +0530 Tuesday, Apurva Shukla wrote:
>> I am a starter in Ada and need certain help regarding arrays. I
>> have got a code in which there is a line which says:
>>
>> a(11..10) := b(1..0);
>>
...
>occurs that, for a (well-designed) generic unit, there will be certain
>(valid and meaningful) instantiations that cause such 'null assignments'.

When null arrays, then an error is raised on a mismatching lengths, by
AARM 4.6(37), which says:

| If the target subtype is a constrained array subtype, then a check is
| made that the length of each dimension of the value of the operand
| equals the length of the corresponding dimension of the target subtype.
| The bounds of the result are those of the target subtype.

--------

There is something unsatisfactory with the handling of empty strings.

In general, the upper and lower bound of a string can be negative.
An incorrect type of coding is to use Natural for the lower bound of a
string.

procedure A is

procedure P (Str : String) is
Low   : constant Positive := Str'First;   --  <- Constraint_Error here
--    High  : constant Natural := Str'Last;
begin
null;
end P;

S  : String := (4 .. 8 => ' ');
T  : constant String := S (-9 .. -10);   --  <- Want sliding to (1..0) ?

begin                                       --  T'First = -9,  T'Last = -10
-- P (Str => S (-9 .. -10));
P (Str => T);
end A;

Is that a significant defect?.
There could be automatic sliding for null strings.

Craig Carey
```