comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Extend slices for n dimensional arrays for Ada 202X
Date: Thu, 26 Jan 2017 12:29:05 -0600
Date: 2017-01-26T12:29:05-06:00	[thread overview]
Message-ID: <o6df5i$i1l$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: df643a73-3e84-4517-ba81-7bc50d0c0d54@googlegroups.com

"Lucretia" <laguest9000@googlemail.com> wrote in message 
news:df643a73-3e84-4517-ba81-7bc50d0c0d54@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.




  parent reply	other threads:[~2017-01-26 18:29 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-26 13:29 REQ: Extend slices for n dimensional arrays for Ada 202X Lucretia
2017-01-26 14:01 ` Lucretia
2017-01-26 14:03   ` Lucretia
2017-01-26 14:52   ` Dmitry A. Kazakov
2017-01-27  9:19     ` Alejandro R. Mosteo
2017-01-27 14:04     ` Lucretia
2017-01-26 18:29 ` Randy Brukardt [this message]
2017-01-27  1:54   ` Robert Eachus
2017-01-27  5:39     ` Robert Eachus
2017-01-27 14:06     ` Lucretia
2017-01-27 23:30     ` Randy Brukardt
2017-01-28  0:58       ` Robert Eachus
2017-01-27  9:34   ` Dmitry A. Kazakov
2017-01-27 13:53     ` G.B.
2017-01-27 14:20       ` Dmitry A. Kazakov
2017-01-27 23:37       ` Randy Brukardt
2017-01-28  9:08         ` Dmitry A. Kazakov
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox