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!o20g2000vbh.googlegroups.com!not-for-mail From: Martin Newsgroups: comp.lang.ada Subject: Re: Use aggregates (Was: Allocation question) Date: Tue, 12 May 2009 00:47:56 -0700 (PDT) Organization: http://groups.google.com Message-ID: <26af755b-0b90-429f-a688-86bf307da2b5@o20g2000vbh.googlegroups.com> References: <4a07fc7a$0$2855$ba620e4c@news.skynet.be> <87prefhq04.fsf@nbi.dk> <62aa80a1-1c0b-4716-ab16-9b6243d97ff2@o27g2000vbd.googlegroups.com> NNTP-Posting-Host: 20.133.0.8 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1242114476 28288 127.0.0.1 (12 May 2009 07:47:56 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 12 May 2009 07:47:56 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: o20g2000vbh.googlegroups.com; posting-host=20.133.0.8; posting-account=g4n69woAAACHKbpceNrvOhHWViIbdQ9G User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:5777 Date: 2009-05-12T00:47:56-07:00 List-Id: On May 11, 1:16=A0pm, Ludovic Brenta wrote: > 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. And not just GNAT...in fact, I'm struggling to remember a compiler that _doesn't_ do the "large and slow (and stupid?)" aggregate for assignment (or initialisation). If paying customers complained compiler vendors might do something to generate more efficient code. Sadly, sometimes the response we got [naming no particular company] was "It meets the RM, we're not doing anything". Cheers -- Martin