"Lucretia" <
lague...@googlemail.com> wrote in message
news:df643a73-3e84-4517...@googlegroups.com...
Hi,
>Array slices are a very powerful feature of the language as it is right
>now, but the fact
>that they are limited to 1-dimensional arrays if short sighted. By having
>slices be
>applicable to all types of arrays would make memory copy operations much
>easier to do and would also eliminate possible array index calculation
>errors that
>we see in other languages.
Maybe much easier for you, but a nightmare for the compiler, as the array
components would not be contiguous in any way. The performance of
> Texture (x1 .. x2, y1 .. y2) := Buffer; -- Buffer is the correct size.
would be roughly the same as explicitly writing the pair of for loops:
for I1 in x1 .. x2 loop
for I2 in y1 .. y2 loop
Texture (I1, I2) := Buffer (I1 - <offset1>, I2 - <offset2>);
end loop;
end loop;
There's no way to speed it up in general.
Moreover, slices are names in Ada, so they can be passed as "in out"
parameters. Consider implementing:
Invert (Texture (x1 .. x2, y1 .. y2));
where the elements of Texture are not continuous.
1-dimensional slices are just that: a contigious slice of an array. That is
true only in unusual cases for multi-dimensional arrays.
The existing implementation of unconstrained arrays is to pass a bounds
descriptor and pointer at the data - such an implementation would not work
here. Moreover, this would cause a distributed overhead -- all parameter
passing of unconstrained multi-dimensional arrays would have support
non-contiguous components, slowing all operations significantly.
For us to even consider such an operation in Ada, its use would have to be
highly constrained, so that its existence would not impact the performance
of other operations (such as the matrix libraries in Annex G). But if that
was the case, then it would look more bolted-on than an integrated feature
of the language. We have enough of those as it is.
So I don't see this happening - it doesn't make sense in the context of Ada
implementation strategies.
Randy.