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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5b3aa4bc9027f04e X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!c36g2000yqn.googlegroups.com!not-for-mail From: sjw Newsgroups: comp.lang.ada Subject: Re: Unconstrained Arrays Date: Thu, 19 Mar 2009 23:45:27 -0700 (PDT) Organization: http://groups.google.com Message-ID: <46281cbb-2804-41e8-87a0-251c9060d4d1@c36g2000yqn.googlegroups.com> References: <1a8008fb-c840-45bc-824c-d10eec9fe569@d36g2000prf.googlegroups.com> <0caa9cf8-0620-4544-9b2c-2c9f24142b7f@v23g2000pro.googlegroups.com> <386b0e00-a1c6-4c5f-adf7-89b8543d0e2d@c11g2000yqj.googlegroups.com> NNTP-Posting-Host: 82.20.239.213 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1237531527 5662 127.0.0.1 (20 Mar 2009 06:45:27 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 20 Mar 2009 06:45:27 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: c36g2000yqn.googlegroups.com; posting-host=82.20.239.213; posting-account=_RXWmAoAAADQS3ojtLFDmTNJCT0N2R4U User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:5170 Date: 2009-03-19T23:45:27-07:00 List-Id: On Mar 20, 1:53=A0am, "Peter C. Chapin" wrote: > belteshazzar wrote innews:386b0e00-a1c6-4c5f-ad= f7-89b8543d0e2d@c11g2000yqj.googlegroups.com: > > > Unfortuantely this is an optimisation and actually doesn't occur with > > optimisation off. (I just ran a test program). I'm told that due to > > the significant performance hit of the array initialisers when > > optimisation is turned off we can't use that. > > Are those initializers actually necessary? > > type Unconstrained_Array is array(Integer range <>) of Integer; > > My_Array : Unconstrained_Array(-10_000 .. 10_000); > > In the above the array is uninitialized. Yes, you have to provide > constraints, but you don't have to initialize the array here (obviously > you'll need to do so eventually... perhaps as part of your algorithm). Th= e > code you showed use an array aggregate to initialize the array... the > constraints where taken from the initializer. However, there are other wa= ys > to specify the constraints. There is a deep language-lawyerly reason (which I don't understand) why an array like your My_Array can't be aliased (at any rate in Ada95); you have to use the initialize-with-aggregate approach. Perhaps that's what leads to the initialize-with-aggregate style.