comp.lang.ada
 help / color / mirror / Atom feed
From: Martin <martin.dowie@btopenworld.com>
Subject: Re: Use aggregates (Was: Allocation question)
Date: Thu, 14 May 2009 03:48:39 -0700 (PDT)
Date: 2009-05-14T03:48:39-07:00	[thread overview]
Message-ID: <2efecfe0-3e76-4bb1-a107-45aa39ea32f6@r3g2000vbp.googlegroups.com> (raw)
In-Reply-To: gufb4g$i8c$1@munin.nbi.dk

On May 13, 9:38 pm, "Randy Brukardt" <ra...@rrsoftware.com> wrote:
> >"Martin" <martin.do...@btopenworld.com> wrote in message
> >news:7b4408e9-386d-471b-aad5-9d26dde12682@v17g2000vbb.googlegroups.com...
> >On May 12, 10:18 pm, "Randy Brukardt" <ra...@rrsoftware.com> wrote:
> >> "Martin" <martin.do...@btopenworld.com> wrote in message
>
> >>news:26af755b-0b90-429f-a688-86bf307da2b5@o20g2000vbh.googlegroups.com...
>
> >> >> 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.
>
> >> >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).
>
> >> You must have not used many Ada compilers.
>
> >The current count is 7 (for my day job) + 3 (for home work).
>
> Fascinating. I'd be interested in seeing an example where you are seeing
> compilers that are doing "large and slow" aggregate initialization or
> assignment, because I have to think we are talking about different things.
>
>                          Randy.

This is going back into the memory banks a bit but here goes...

Situations like:

package P is
   type R is record
      I : Integer;
      F : Float;
      B : Boolean;
   end record;
   type Index is range 1 .. 100;
   type A_Of_R is array (Index) of R;
   D : A_Of_R;
end P;

package P is
   ...
begin
   D := (others => (I => 100, F => 1.0, B => False));
end A;

Quite possibly 'R' has, on some projects, had a discriminant. On
others, it may have been an array of an array. On others again, 'R'
may have been 'private' and a 'Null_R' private constant exported and
used to initialise 'Data' in some other compilation unit.

Also, to be fair, the last time I came across this in production code
was a few years ago. I'm certainly not claiming that I've found every
Ada compiler I've ever used has down something 'slow'...I almost
certainly haven't had this sort of construct in every project I've
work on. I've only noticed it a small number of times when it became a
problem for our timing requirements.

But it was rather off-putting to be told 'it meets the RM - tough!.

Cheers
-- Martin



  reply	other threads:[~2009-05-14 10:48 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     ` Use aggregates (Was: Allocation question) Martin
2009-05-12 10:24       ` 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 [this message]
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