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.3 required=5.0 tests=BAYES_00,INVALID_MSGID 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: Ted Dennison Subject: Re: Elaboration order Date: 1996/03/16 Message-ID: <314A5334.AB@escmail.orl.mmc.com>#1/1 X-Deja-AN: 142996241 references: <314701A1.469D@lfwc.lockheed.com> <1996Mar14.021345.9856@enterprise.rdd.lmsc.lockheed.com> <314829CD.4FA9@lfwc.lockheed.com> content-type: text/plain; charset=us-ascii organization: Lockheed Martin Marine Systems mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 2.0 (X11; I; HP-UX A.09.01 9000/750) Date: 1996-03-16T00:00:00+00:00 List-Id: Ken Garlington wrote: > > Chris McKnight wrote: > > > > LRM References? Hmm.. how about (taken from ANSI/MIL-STD-1815A-1983): > > > > 7.3 paragraph 4 : > > "The elaboration of the body of a subprogram declared in the visible > > part of a package is caused by the elaboration of the body of the > > package. Hence a call of such a subprogram by an outside program > > unit raises the exception PROGRAM_ERROR if the call takes place > > before the elaboration of the package body" > > So what does this mean in the following case: ... (code removed to placate facist newsreader).... > 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, and (depending on your style) Yes. Generally, the rule is that subprogram calls are safe once the first line of code in the main routine is reached. Any call to a subprogram in another package from the declarations and the body code of another package (the part between the "begin" and the "end Use_Example;") and I think just about ANYWHERE in a task, can potentially raise PROGRAM_ERROR (and is thus erronious w/o a pragma elaborate). Calls to subprograms from pacakge specifications are particularly likely to raise this error. There are all sorts of subtleties I'm brushing over here, but this is the general idea. Failure to account for this in the design phase can lead to problems at a seemingly random future date. The code may just happen to elaborate in the right order, but one day a unit will be added or deleted, and (***BOOM!****). The full description of how this is supposed to work (in Ada 83) can be found in section 10.5 (Elaboration of Library Units) of the LRM. -- T.E.D. | Work - mailto:dennison@escmail.orl.mmc.com | | Home - mailto:dennison@iag.net | | URL - http://www.iag.net/~dennison |