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,183821e6c098051b X-Google-Attributes: gid103376,public From: "Thierry Lelegard" Subject: Re: pragma Elaborate (Comp. Unit) question. Date: 1999/05/22 Message-ID: <7i75ko$6km$1@front3.grolier.fr>#1/1 X-Deja-AN: 480984336 Content-Transfer-Encoding: 7bit References: <37458C65.3393@pipeline.com> X-Trace: front3.grolier.fr 927406552 6806 194.158.116.180 (22 May 1999 20:55:52 GMT) Organization: Club-Internet (France) X-MSMail-Priority: Normal X-Priority: 3 Content-Type: text/plain; charset="iso-8859-1" Mime-Version: 1.0 NNTP-Posting-Date: 22 May 1999 20:55:52 GMT X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211 Newsgroups: comp.lang.ada Date: 1999-05-22T20:55:52+00:00 List-Id: > That is, if the compiler knows what the elaboration order needs to be > why can't it make the relavant deterministic change and proceed with a > warning? > > Is it because elaboratation is by definition non-deterministic and if > so why is it that way? The correct order of elaboration is deterministic but many cases cannot be detected during compilation, not even during link. The developer is the only one to know (sometimes he does even know :-)) Example: 1) package A ... 2) with A; package body B ... 3) with B; package body C ... Let's assume that B does not call any subprogram of A during its elaboration. So, the author of B thinks that B does not need a pragma Elaborate (A). C calls some subprograms of B during its elaboration. So, the author of C adds a pragma Elaborate (B). However, he/she does not know that the body of B references A (he/she may even not know the existence of A). Let's assume that the subprogram of B which is called during elaboration of C calls a subprogram of A. The following elaboration order is valid for the binder but will raise a program_error during the elaboration of C: spec A spec B spec C body B (before body C because of pragma elaborate) body C (elab: calls B, which in turn calls A) body A (no pragma told me to elaborate sooner) In Ada 95, the pragma Elaborate_All fixes this: The author of C would write pragma Elaborate_All (B). But you are using Ada 83, too bad... One brute force way of fixing the problem in Ada 83 is to add a pragma elaborate for each "with" clause, everywhere. I even once wrote a tool to do that automatically! But there can be some circularity problems: package A is... package B is... with B; package body A is... with A; package body B is... Although poor design, this is valid. Adding a pragma elaborate everywhere would create a circularity which cannot be solved by the binder. You have to know exactly which uses which during elaboration and set only the required pragmas. -Thierry ________________________________________________________ Thierry Lelegard, Paris, France E-mail: lelegard@club-internet.fr