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.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1ff5003422436e4 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-11-01 13:56:54 PST Newsgroups: comp.lang.ada Path: nntp.gmd.de!newsserver.jvnc.net!news.cac.psu.edu!news.tc.cornell.edu!loghost.sdsc.edu!news.cerf.net!shrike.irvine.com!adam From: adam@irvine.com (Adam Beneschan) Subject: Re: Easily-Read C++? In-Reply-To: bobduff@dsd.camb.inmet.com's message of Thu, 27 Oct 1994 14:54:46 GMT References: <389vqv$i6n@source.asset.com> <38k8g2INNiff@marble.summit.novell.com> Sender: usenet@irvine.com (News Administration) Organization: Irvine Compiler Corp., Irvine, California, USA Date: Tue, 1 Nov 1994 21:19:27 GMT Message-ID: Date: 1994-11-01T21:19:27+00:00 List-Id: bobduff@dsd.camb.inmet.com (Bob Duff) writes: > In article <38k8g2INNiff@marble.summit.novell.com>, > -mlc-+Schilling J. wrote: > >Pragma Suppress doesn't relate to carrying around array bounds at runtime, > >but rather to whether index checks are done. If the array bounds are > >dynamic, then it is necessary to carry them around in order to generate > >correct indexing offset code, whether or not you are also doing the checks. > > I don't think that's quite right. The compiler can always store the > address of the zero-th element (even if there is no such element), and > then the indexing calculation doesn't need to subtract the lower bound. > Thus, if checks are suppressed, there should be no need to store the > bounds. > > On the other hand, if there are any whole-array assignments, then the > size has to be stored (or some information from which the size can be > calculated). Also, if you use the 'FIRST, 'LAST, 'RANGE, or 'LENGTH attributes, you will need to carry the bounds. Otherwise the following can't be compiled: pragma SUPPRESS (ALL_CHECKS); type INT_ARRAY is array (NATURAL range <>) of INTEGER; function SUM (A : INT_ARRAY) return INTEGER is RESULT : INTEGER; begin RESULT := 0; for I in A'RANGE loop RESULT := RESULT + A(I); end loop; return RESULT; end SUM; I suppose that your suggestion will work if the *only* operation you perform on a dynamic one-dimensional array is indexing, but quite frankly I can't imagine anyone wanting to write a routine that takes a dynamic array, uses only indexing, and doesn't use 'FIRST, 'LAST, or 'RANGE (or pass the array on to another routine that does). Also, it should be noted that your suggestion won't work on dynamic two-dimensional or higher-dimensional arrays. -- Adam