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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,16e3a8dd4f3ab3f3 X-Google-Attributes: gid103376,public From: jwierzbo@hercii.lasc.lockheed.com (Joe Wierzbowski) Subject: Re: Elaboration order Date: 1996/03/16 Message-ID: <1996Mar16.213029.24934@enterprise.rdd.lmsc.lockheed.com>#1/1 X-Deja-AN: 143191053 sender: news@enterprise.rdd.lmsc.lockheed.com (News Administrator) references: <314829CD.4FA9@lfwc.lockheed.com> organization: Lockheed Martin Aeronautical Systems reply-to: jwierzbo@hercii.lasc.lockheed.com newsgroups: comp.lang.ada Date: 1996-03-16T00:00:00+00:00 List-Id: In article 4FA9@lfwc.lockheed.com, Ken Garlington () writes: > < snip > > > So what does this mean in the following case: > > package Another_Example is > > function Initial_Value return Integer; > > end; > > package body Another_Example is > > function Initial_Value return Integer is begin return 0; end; > > end; > > with Another_Example; > package Use_Example is > > X : Integer := Another_Example.Initial_Value; > > end; > > Can I get a Program_Error on the initialization of X? If so, > it would seem like there would need to be a pragma > Elaborate for nearly every reference to every package > exporting a subprogram! Yes, you can get Program_Error on the initialization of X. The important point here for Ada 83 is that this requirement refers to declarative regions. So your choices are: 1) Add a pragma Elaborate for each subprogram called during a declarative region or 2) Don't make initial assignments using subprogram calls in a declarative region. This is a common mistake, so much so that it may be worth adding a restriction against doing so in a coding standard. I can tell you that it's almost always the first thing to bite you during integration; there's always someone who has an elaboration order problem. Another thing to note here is that Ada 95 provides convenient ways of elaborating every required package (See Robert Duff's posting).