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-Thread: 103376,23dabf88feae3dba X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread3.news.pas.earthlink.net.POSTED!14bb18d8!not-for-mail Sender: Matthew Heaney@MHEANEYIBMT43 Newsgroups: comp.lang.ada Subject: Re: Elaboration worries References: <4fssh9F1ena5jU1@individual.net> From: Matthew Heaney Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 22 Jun 2006 02:24:24 GMT NNTP-Posting-Host: 24.149.57.125 X-Complaints-To: abuse@earthlink.net X-Trace: newsread3.news.pas.earthlink.net 1150943064 24.149.57.125 (Wed, 21 Jun 2006 19:24:24 PDT) NNTP-Posting-Date: Wed, 21 Jun 2006 19:24:24 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: g2news2.google.com comp.lang.ada:4893 Date: 2006-06-22T02:24:24+00:00 List-Id: Robert A Duff 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.