From: mheaney@on2.com (Matthew Heaney)
Subject: Re: Elaboration of nested generic package.
Date: 14 Jul 2003 11:35:01 -0700
Date: 2003-07-14T18:35:02+00:00 [thread overview]
Message-ID: <1ec946d1.0307141035.3f1e4b80@posting.google.com> (raw)
In-Reply-To: wcc65m8pwq1.fsf@shell01.TheWorld.com
Robert A Duff <bobduff@shell01.TheWorld.com> wrote in message news:<wcc65m8pwq1.fsf@shell01.TheWorld.com>...
> mheaney@on2.com (Matthew Heaney) writes:
>
> > I would still like a definitive answer, though. In order to make a
> > library-level package instantiation, do I need to use Elaborate_All on
> > the generic unit? (As in the example above.)
>
> If the generic unit says Elaborate_Body, then you do not. However,
> Elab_Body causes a problem: the body can't "with" its own children,
> which is often useful.
>
> If you don't have Elab_Body, and you say "with Some_Generic", then you
> should normally Elab_All of the generic, because your instances will
> normally be at library level. If your instances are nested in
> procedures, then you don't normally need to do that. There are some
> rare cases where Elab_All won't work, and you have to use pragma
> Elaborate instead.
>
> This part of the language is something of a mess. Pragma Elaborate was
> added late in the game of Ada 83, and it was later realized that it
> doesn't work well, and we tried to fix it in Ada 95, and pretty much
> failed. We added some pragmas, but as evidenced by this thread, it's
> not always clear when to use them.
>
> But if you use GNAT in its default mode, it will tell you where you need
> the pragmas, mostly. It doesn't work in the case of
> indirect/dispatching calls, though.
>
> > Also: do the categorization pragmas in a generic unit make any
> > difference? In other words, you still need to say Elaborate_All,
> > irrespective of what the generic unit says about categorization --
> > correct?
>
> I think there is an AI on this point. Sorry, I don't remember the
> details.
Things are even more weird, at least wrt GNAT.
I have this:
generic
...
package GP is
pragma Preelaborate;
...
end GP;
And then I instantiate it, like this:
with GP;
pragma Elaborate_All (GP);
package P is new GP (...);
I then with it from a normal packet that has a categorization pragma:
with P;
package Q is
pragma Preelaborate;
...
end Q;
What's weird is that the compiler is telling me I'm not allowed to
with P from a preelaborate package Q. I was surprised by this
behavior, because GP says explicitly that it is Preelaborate
categorization.
To make the compiler happy I have to use a confirming pragma on the
instantion of GP:
with GP;
pragma Elaborate_All (GP);
package P is new GP (...);
pragma Preelaborate (P);
and then Q compiles without error.
Is this normal behavior? This is the reason I was asking whether the
categorization pragmas do anything if they're declared in a generic
package.
Is it necessary to use a categorization pragma on library-level
package instantiations?
-Matt
next prev parent reply other threads:[~2003-07-14 18:35 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-07-02 4:13 Elaboration of nested generic package christoph.grein
2003-07-08 3:05 ` Don Westermeyer
2003-07-08 17:46 ` Matthew Heaney
2003-07-10 1:10 ` Don Westermeyer
2003-07-10 1:35 ` Robert I. Eachus
2003-07-10 4:51 ` Robert I. Eachus
2003-07-10 6:58 ` Jean-Pierre Rosen
2003-07-10 15:08 ` Robert I. Eachus
2003-07-11 21:26 ` Robert A Duff
2003-07-10 14:12 ` Matthew Heaney
2003-07-10 15:39 ` Robert I. Eachus
2003-07-11 21:41 ` Robert A Duff
2003-07-14 18:35 ` Matthew Heaney [this message]
2003-07-15 17:19 ` Randy Brukardt
2003-07-16 15:24 ` Matthew Heaney
2003-07-17 2:08 ` Randy Brukardt
2003-07-17 15:54 ` Richard Riehle
2003-07-10 15:03 ` Don Westermeyer
2003-07-10 15:45 ` Matthew Heaney
-- strict thread matches above, loose matches on Subject: below --
2003-07-09 5:21 christoph.grein
2003-07-01 20:14 Don Westermeyer
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox