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,6a8545673e1817b5 X-Google-Attributes: gid103376,public From: ncohen@watson.ibm.com (Norman H. Cohen) Subject: Re: Order of elaboration Date: 1996/04/03 Message-ID: <4jtufg$h13@watnews1.watson.ibm.com>#1/1 X-Deja-AN: 145598662 distribution: world references: <4jtggm$ipm@mal9000.mal.com> organization: IBM T.J. Watson Research Center reply-to: ncohen@watson.ibm.com newsgroups: comp.lang.ada Date: 1996-04-03T00:00:00+00:00 List-Id: In article <4jtggm$ipm@mal9000.mal.com>, dgymer@mal9000.mal.com (Dave 'Gizmo' Gymer) writes: |> Having waded through most of John Barnes' Ada95 book and made a lot of |> progress with some CGI stuff, I can't quite decide whether the |> following must always be true; it makes sense but I can't find |> explicit confirmation in either Barnes' book or in RM95: |> |> A child package must always be elaborated after it's parent(s). Be careful to distinguish between program units and compilation units! A package is a program unit. If it is a library package, this program unit typically consists of two compilation units--the package declaration and the package body. Elaboration is something defined for compilation units. Thus it makes no sense to speak of when a package is elaborated. Instead, you can speak of when a package declaration is elaborated and when a package body is elaborated. The declaration of a child package must indeed be elaborated after the declaration of its parent's declaration. However, the body of the parent can be elaborated any time after the declaration of the parent (before the elaboration of the child declaration, between the elaboration of the child declaration and the child body, or after the declaration of the child body): parent declaration / \ parent body child declaration | child body |> So if the parent sets up an empty list and has some functions for |> adding things to that list, the child can call those functions (sorry, |> procedures; I'm still recovering from C++) without worrying about |> whether the list has been initialized yet (and without using the |> Elaborate pragma). Correct? Incorrect. You can't call those subprograms until the parent body has been elaborated. For one thing, if the initialization to an empty list takes place inside the package body rather than the package declaration, that won't happen until the package body has been elaborated. For another, the bodies of subprograms provided by the package are not elaborated until the package body containing them is elaborated, and you can't call a subprogram until its body has been elaborated. If you put an Elaborate_Body pragma inside the parent package declaration, it will force the parent body to be elaborated immediately after the parent declaration, solving your problem. Alternatively, you could put an Elaborate or Elaborate_All pragma in the context clause of whichever compilation unit (the child declaration or the child body) calls the parent package's subprograms. -- Norman H. Cohen ncohen@watson.ibm.com