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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b1264e586250f470 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-11 14:42:21 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Elaboration of nested generic package. Date: 11 Jul 2003 17:41:42 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <5437fafb.0307071905.5d3bbc4e@posting.google.com> <1ec946d1.0307080946.7e61cda9@posting.google.com> <5437fafb.0307091710.5cb4b0eb@posting.google.com> <3F0CC2D1.10904@attbi.com> <1ec946d1.0307100612.20a3d000@posting.google.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1057959702 2335 199.172.62.241 (11 Jul 2003 21:41:42 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 11 Jul 2003 21:41:42 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:40211 Date: 2003-07-11T17:41:42-04:00 List-Id: mheaney@on2.com (Matthew Heaney) writes: > "Robert I. Eachus" wrote in message news:<3F0CC2D1.10904@attbi.com>... > > Don Westermeyer wrote: > > > > > Usually I do use pragma Elaborate_All for every dependancy anyway > > > since one does not have control over every software module developed. > > > Using it is always safer and causes no penalties that I know of > > > (assuming the design stays clear of mutual dependancies). > > > > This is silly. The reason that Ada doesn't automagically assume > > Elaborate_Body or Elaborate_All, is that there is a better assumption. > > The implementation knows the potential elaboration issues and is > > encouraged to chose one that cannot result in Program_Error. > > I was talking about library-level instantiations of generic packages. > > Back in 1997, Bob Duff and Robert Dewar seemed to suggest that you > always need Elaborate_All on the generic package: > > with GP; > pragma Elaborate_All (GP); --Do you need this pragma... > package P is new GP; --...in order to instantiate? > > If we're not talking about with'ing a generic package, then I agree > that it is silly to use the Elaborate_All on every dependency. It > only makes it harder for the compiler to find an acceptable > elaboration order, because you have constrained the size of the set of > possible orders. > > You should only use it when the dependent unit calls subprograms > provided by the with'd unit during its own elaboration. > > > > Using pragma Elaborate, Elaborate_All, or Elaborate_Body > > indiscriminantly can only make the Ada compiler's job harder. There are > > two exceptions though. If you know that the subprograms declared in a > > package are used before the main program is elaborated, by all means use > > Elaborate_All. > > Yes. > > 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. - Bob