comp.lang.ada
 help / color / mirror / Atom feed
From: Martin <martin.dowie@btopenworld.com>
Subject: Re: Use aggregates (Was: Allocation question)
Date: Tue, 12 May 2009 00:47:56 -0700 (PDT)
Date: 2009-05-12T00:47:56-07:00	[thread overview]
Message-ID: <26af755b-0b90-429f-a688-86bf307da2b5@o20g2000vbh.googlegroups.com> (raw)
In-Reply-To: 62aa80a1-1c0b-4716-ab16-9b6243d97ff2@o27g2000vbd.googlegroups.com

On May 11, 1:16 pm, Ludovic Brenta <ludo...@ludovic-brenta.org> wrote:
> Jacob Sparre Andersen wrote on comp.lang.ada:
>
>
>
> > Olivier Scalbert wrote:
> > > procedure Fill(Image: in out Image_T; Color: Color_T) is
> > > begin
> > >       for x in Image'range(1) loop
> > >           for y in Image'range(2) loop
> > >               Image(x,y) := Color;
> > >           end loop;
> > >       end loop;
> > > end Fill;
>
> > I would sugges that you rather wrote this:
>
> >    Image := (others => (others => 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



  parent reply	other threads:[~2009-05-12  7:47 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-11 10:23 Allocation question Olivier Scalbert
2009-05-11 10:38 ` Georg Bauhaus
2009-05-11 10:40 ` Ludovic Brenta
2009-05-11 12:14   ` Olivier Scalbert
2009-05-11 12:18     ` Ludovic Brenta
2009-05-11 13:01       ` Olivier Scalbert
2009-05-11 12:26   ` Jacob Sparre Andersen
2009-05-11 13:27     ` Ludovic Brenta
2009-05-11 10:51 ` Use aggregates (Was: Allocation question) Jacob Sparre Andersen
2009-05-11 11:46   ` Olivier Scalbert
2009-05-11 12:16   ` Ludovic Brenta
2009-05-11 21:26     ` sjw
2009-05-12  5:58       ` GNAT, aggregates and efficiency (Was: Use aggregates) Jacob Sparre Andersen
2009-05-12 18:57         ` sjw
2009-05-12  7:47     ` Martin [this message]
2009-05-12 10:24       ` Use aggregates (Was: Allocation question) Brian Drummond
2009-05-12 11:07         ` Georg Bauhaus
2009-05-12 11:14           ` Georg Bauhaus
2009-05-12 21:18       ` Randy Brukardt
2009-05-13 16:38         ` Martin
2009-05-13 20:38           ` Randy Brukardt
2009-05-14 10:48             ` Martin
2009-05-12  9:13   ` Emacs Stephen Leake
2009-05-12  9:38     ` Emacs Ludovic Brenta
2009-05-12  9:46     ` Emacs Olivier Scalbert
2009-05-11 10:57 ` Allocation question Philipp Riegger
2009-05-11 12:18   ` Georg Bauhaus
2009-05-11 12:36     ` Philipp Riegger
2009-05-11 23:32 ` Brian Drummond
2009-05-12  1:09 ` tmoran
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox