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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1ce0ce3b2db00698 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.190.104 with SMTP id gp8mr18029841pbc.4.1340749038311; Tue, 26 Jun 2012 15:17:18 -0700 (PDT) Path: l9ni23460pbj.0!nntp.google.com!news1.google.com!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: how to print an array range? Date: Wed, 27 Jun 2012 00:17:13 +0200 Organization: cbb software GmbH Message-ID: References: <4fe9bf33$0$6566$9b4e6d93@newsspool4.arcor-online.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: q1gJPV1SC/KP9ydRbYoWiw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2012-06-27T00:17:13+02:00 List-Id: On Tue, 26 Jun 2012 17:31:31 -0400, Robert A Duff wrote: > Why didn't they make the index subtype Positive (or > maybe Natural) instead of Integer? Why should they limit index to a subset which would have more problems with not being closed upon arithmetic operations than Integer? The only real constraint here is the array bounds. Ideally index should be Universal_Integer. > Is it important to allow negative index values? Yes, there were several cases I used a negative lower bound. One important case is when you have a n-elements thick border around the original matrix filled with some special values, usually zeros. This technique is used when matrix elements are convoluted. E.g. let you compute something like diagonal sums like: A(I - 2, J) + A(I - 1, J) + A (I, J) + A (I + 1, J) + A (I + 2, J) You don't want to check I for special border cases A'First (1), A'First (1) + 1, A'Last (1) - 1, A'Last (1). Instead of that you add a border of zeros, trading a little space for index checks, and get more uniform and efficient code. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de