comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison <dennison@escmail.orl.mmc.com>
Subject: Re: Elaboration order
Date: 1996/03/16
Date: 1996-03-16T00:00:00+00:00	[thread overview]
Message-ID: <314A5334.AB@escmail.orl.mmc.com> (raw)
In-Reply-To: 314829CD.4FA9@lfwc.lockheed.com

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         |




  parent reply	other threads:[~1996-03-16  0:00 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <314701A1.469D@lfwc.lockheed.com>
1996-03-15  0:00 ` Elaboration order Robert I. Eachus
1996-03-15  0:00   ` Robert Dewar
     [not found] ` <1996Mar14.021345.9856@enterprise.rdd.lmsc.lockheed.com>
     [not found]   ` <314829CD.4FA9@lfwc.lockheed.com>
1996-03-15  0:00     ` Tucker Taft
1996-03-15  0:00       ` Ken Garlington
1996-03-16  0:00     ` Joe Wierzbowski
1996-03-26  0:00       ` AdaWorks
1996-03-26  0:00         ` Robert Dewar
1996-03-26  0:00           ` IO in Pure packages, debugging Laurent Guerby
1996-03-26  0:00           ` Elaboration order Robert A Duff
1996-03-26  0:00             ` Robert Dewar
1996-03-26  0:00         ` Robert A Duff
1996-03-16  0:00     ` Ted Dennison [this message]
1996-03-26  0:00     ` Laurent Guerby
1996-03-26  0:00       ` Robert A Duff
1996-03-18  0:00 ` Ted Dennison
1996-03-18  0:00 ` Ken Garlington
1996-03-19  0:00 ` Michel Gauthier
1996-03-20  0:00 ` DenReimer
1996-03-20  0:00   ` Norman H. Cohen
1996-03-20  0:00   ` Robert A Duff
1996-03-20  0:00     ` Norman H. Cohen
1996-03-20  0:00       ` Robert Dewar
1996-03-20  0:00   ` Tucker Taft
     [not found] ` <Do8JDv.A2v@world.std.com>
     [not found]   ` <31494143.3825@lfwc.lockheed.com>
1996-03-15  0:00     ` Mark A Biggar
1996-03-18  0:00       ` Ken Garlington
1996-03-19  0:00         ` Chris McKnight
1996-03-21  0:00           ` Ken Garlington
1996-03-19  0:00         ` Norman H. Cohen
1996-03-20  0:00           ` Cordes MJ
1996-03-19  0:00             ` Robert Dewar
1996-03-21  0:00               ` Ken Garlington
1996-03-21  0:00               ` Cordes MJ
1996-03-20  0:00             ` Robert A Duff
1996-03-20  0:00               ` Cordes MJ
1996-03-20  0:00                 ` Robert A Duff
1996-03-22  0:00                   ` Cordes MJ
1996-03-20  0:00                 ` Robert Dewar
1996-03-21  0:00                   ` Ken Garlington
1996-03-23  0:00                 ` JP Thornley
1996-03-25  0:00                   ` Robert Dewar
1996-03-26  0:00                 ` JP Thornley
1996-03-15  0:00     ` Robert A Duff
     [not found]       ` <EACHUS.96Mar18143219@spectre.mitre.org>
1996-03-18  0:00         ` Robert Dewar
1996-03-18  0:00         ` Robert Dewar
1996-03-19  0:00           ` Ted Dennison
1996-03-20  0:00         ` David Emery
1996-03-18  0:00       ` Norman H. Cohen
1996-03-20  0:00   ` Robert I. Eachus
1996-03-22  0:00   ` Robert I. Eachus
1996-03-22  0:00   ` Robert I. Eachus
1999-11-15  0:00 Elaboration Order Wolf-Dieter Heker
1999-11-15  0:00 ` Jean-Pierre Rosen
1999-11-15  0:00   ` Robert Dewar
1999-11-16  0:00     ` Jean-Pierre Rosen
1999-11-20  0:00       ` Simon Wright
1999-11-15  0:00 ` Robert Dewar
1999-11-16  0:00   ` Wolf-Dieter Heker
1999-11-16  0:00     ` David C. Hoos, Sr.
1999-11-16  0:00     ` Robert Dewar
1999-11-16  0:00     ` Robert Dewar
1999-11-20  0:00       ` Simon Wright
1999-11-22  0:00         ` Robert Dewar
1999-11-23  0:00           ` Mats Weber
  -- strict thread matches above, loose matches on Subject: below --
1996-03-18  0:00 Elaboration order Jean-Pierre Rosen
1996-03-21  0:00 ` Ken Garlington
     [not found] <DoDMLL.1F9@world.std.com>
1996-03-18  0:00 ` Chris McKnight
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox