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!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: REQ: Extend slices for n dimensional arrays for Ada 202X Date: Thu, 26 Jan 2017 15:52:02 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <0fbd77dd-bcc2-462c-9ca3-be1ffb51e0c6@googlegroups.com> NNTP-Posting-Host: vZYCW951TbFitc4GdEwQJg.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:33177 Date: 2017-01-26T15:52:02+01:00 List-Id: On 26/01/2017 15:01, Lucretia wrote: > On Thursday, 26 January 2017 13:29:47 UTC, Lucretia wrote: > >> >> Texture (x1 .. x2, y1 .. y2) := Buffer; -- Buffer is the correct size. > > I forgot to mention something else. I put the above notation down as > someone in #Ada liked tha, but I would prefer the following: > > Texture (x1, y1 .. x2, y2) := Buffer; -- Buffer is the correct size. I don't understand the latter. (X1, Y1) .. (X2, Y2) is not a submatrix it is a linear slice: I 1 2 3 4 ------- 1 | a b c d 2 | e f g h 3 | i j k l 4 | m n o p Submatrix 1..2, 2..4 is 1 2 3 ----- 1 | b c d 2 | f g h (1,2) .. (2,4) is a vector 1 | b 2 | c 3 | d 4 | e 5 | f 6 | g 7 | h > The reasoning is as follows: > > 1) That is easier for people to visualise. > 2) That follows how n-dimensional arrays are accessed in Ada, i.e. > > procedure Test is > type Matrix is array (1 .. 4, 1 .. 4) of Float; > > I : Matrix; > begin > I (1, 4) := 0.0; > end Test; It does not follow. The indexing notation is as a tuple I1 x I2 x ... x IN Where Ik is either a singleton (collapsed dimension) or a subset of the index (in Ada a range). With generic subsets I ({1,2},{2,4}) would mean 1 2 --- 1 | b d 2 | f g You forgot notation for whole index range: I (<>, 1) -- column 1. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de