comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthewjheaney@earthlink.net>
Subject: Re: Elaboration worries
Date: Thu, 22 Jun 2006 02:24:24 GMT
Date: 2006-06-22T02:24:24+00:00	[thread overview]
Message-ID: <uzmg66i7d.fsf@earthlink.net> (raw)
In-Reply-To: wccodwmumzk.fsf@shell01.TheWorld.com

Robert A Duff <bobduff@shell01.TheWorld.com> writes:

> Yes, that's because generic instantiations are usually at library level,
> and are therefore elaborated at library package elab time.

Just to add to what Bob says here (and to paraphrase what he has recommended in
other threads on this topic), you need to pragma Elaborate_All whenever you do
an instantiation, e.g.

with GP;
pragma Elaborate_All (GP);

package Q is
   pragma Preelaborate; -- or whatever
   package P is new GP (...);
   ...
end Q;

with GR;
pragma Elaborate_All (GR);

package body Q is
  package R is new GR (...);
  ...
end Q;


The Charles library and the GNAT implementation of the standard container
library are implemented like that, with an Elaborate_All on the generic package
being instantiated.

Note that I don't usually bother using pragma Elaborate_Body unless I need to
either force a body for a spec that otherwise wouldn't require a body, or
because the body has state.  In the latter case you want to ensure that the
package state is fully elaborated before any operations in that package are
called (by some other package during its own elaboration).

Of course if, during elaboration of a package, the package calls an operation
in some other package, then the package must Elaborate_All on the called
package.

Normally you want pragma Elaborate_All, but pragma Elaborate is still useful
occasionally, when elaborating packages with mutual dependencies.



  reply	other threads:[~2006-06-22  2:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-21 12:33 Elaboration worries Alex R. Mosteo
2006-06-21 18:01 ` Samuel Tardieu
2006-06-21 20:34 ` Randy Brukardt
2006-06-21 23:07   ` Samuel Tardieu
2006-06-22 23:06     ` Randy Brukardt
2006-06-23 18:42       ` Samuel Tardieu
2006-06-23 19:54         ` Randy Brukardt
2006-06-21 23:12   ` Robert A Duff
2006-06-22 23:09     ` Randy Brukardt
2006-06-21 23:07 ` Robert A Duff
2006-06-22  2:24   ` Matthew Heaney [this message]
2006-06-22 10:36 ` Alex R. Mosteo
2006-06-22 16:25   ` Alex R. Mosteo
2006-06-22 23:31   ` Randy Brukardt
replies disabled

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