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!feeder.eternal-september.org!news.mixmin.net!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Community Input for the Maintenance and Revision of the Ada Programming Language Date: Fri, 8 Sep 2017 23:46:26 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <4dc188de-802b-41ad-9cdd-b8246eb9a1c7@googlegroups.com> <47cc6474-8b75-4644-92d0-bd1f694c20e7@googlegroups.com> <338b355a-dee4-4c73-b00e-09d9a8430fb1@googlegroups.com> <21692daf-5a52-43f0-a72a-d79e6a7dcc9f@googlegroups.com> NNTP-Posting-Host: MajGvm9MbNtGBKE7r8NgYA.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 X-Notice: Filtered by postfilter v. 0.8.2 Content-Language: en-US Xref: news.eternal-september.org comp.lang.ada:47986 Date: 2017-09-08T23:46:26+02:00 List-Id: On 2017-09-08 23:04, Johan Söderlind Åström wrote: > I would really like to write, for a example: > (A (I) + B (I)) * C (I) / (D (I) ** E (I)); > instead of: > (A (A'First + I) + B (B'First + I)) * C (C'First + I) / (D (D'First + I) ** E (E'First + I)); > ... you know for obvious reason. Since these things are usually happen in a loop the compiler might have issues with eliminating index checks. Because you would replace for I in A'Range loop ... (A (I) + B (I)) * C (I) / (D (I) ** E (I)) ... end loop; with for I in 0..A'Length - 1 loop ... (A (I) + B (I)) * C (I) / (D (I) ** E (I)) ... end loop; BTW, the code usually looks even uglier: for I in A'Range loop ... (A (I) + B (I + B'First - A'First)) * C (I + C'First - A'First) / (D (I + D'First - A'First) ** E (I + E'First - A'First)) ... end loop; However, it is easier to optimize, I guess. To me it is the loop, which should have a form to walk through several congruent arrays. E.g. using conventional mathematical notation: for I,J,K,L,M in A'Range,B'Range,C'Range,D'Range,E'Range loop ... (A (I) + B (J)) * C (K) / (D (L) ** E (M)) ... end loop; Positional indexing is another issue. Position /= index. Position is always an ordinal number. It is the same type for all array types. Array index is any discrete type, not necessarily integer, and maybe specific for each array type. Ordinal numbers can be used for indexing using S'Val () attribute where S is the array index subtype. It is extremely ugly but useful when the array index type is not numeric. I am for adding positional array element access. But it must have a clearly distinct syntax. E.g. either by using square brackets: A [Position] or per attribute: A'Nth (Position) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de