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=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,aa14979d20ba3045 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!o27g2000vbd.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Use aggregates (Was: Allocation question) Date: Mon, 11 May 2009 05:16:02 -0700 (PDT) Organization: http://groups.google.com Message-ID: <62aa80a1-1c0b-4716-ab16-9b6243d97ff2@o27g2000vbd.googlegroups.com> References: <4a07fc7a$0$2855$ba620e4c@news.skynet.be> <87prefhq04.fsf@nbi.dk> NNTP-Posting-Host: 153.98.68.197 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1242044162 5505 127.0.0.1 (11 May 2009 12:16:02 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 11 May 2009 12:16:02 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: o27g2000vbd.googlegroups.com; posting-host=153.98.68.197; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:5759 Date: 2009-05-11T05:16:02-07:00 List-Id: Jacob Sparre Andersen wrote on comp.lang.ada: > Olivier Scalbert wrote: > > procedure Fill(Image: in out Image_T; Color: Color_T) is > > begin > > =A0 =A0 =A0 for x in Image'range(1) loop > > =A0 =A0 =A0 =A0 =A0 for y in Image'range(2) loop > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 Image(x,y) :=3D Color; > > =A0 =A0 =A0 =A0 =A0 end loop; > > =A0 =A0 =A0 end loop; > > end Fill; > > I would sugges that you rather wrote this: > > =A0 =A0Image :=3D (others =3D> (others =3D> Color)); > > It is a more precise expression of what (I guess) you want done, and > thus it gives the compiler more precise information to work with. This is not always a good idea. On some targets, GNAT places the aggregate on the stack and this can raise a Storage_Error. In avionics programs, I remember replacing aggregates with loops for this reason. -- Ludovic Brenta.