From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!reality.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Extend slices for n dimensional arrays for Ada 202X Date: Thu, 26 Jan 2017 12:29:05 -0600 Organization: JSA Research & Innovation Message-ID: References: NNTP-Posting-Host: rrsoftware.com X-Trace: franka.jacob-sparre.dk 1485455346 18485 24.196.82.226 (26 Jan 2017 18:29:06 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 26 Jan 2017 18:29:06 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:33182 Date: 2017-01-26T12:29:05-06:00 List-Id: "Lucretia" 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 - , I2 - ); 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.