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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,878cc452376823e0 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!feeder.news-service.com!news.motzarella.org!motzarella.org!not-for-mail From: =?ISO-8859-1?Q?S=E9bastien?= Newsgroups: comp.lang.ada Subject: Re: Generic body Date: Thu, 15 May 2008 15:40:27 +0000 Organization: A noiseless patient Spider Message-ID: <482C596B.5080609@gmail.com> References: <482C0178.5020501@gmail.com> <511b5387-c94f-4293-91f0-d8a4c4447894@u12g2000prd.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: feeder.motzarella.org U2FsdGVkX1/viH/WwK5I/vOIfU2Qrt4Vgv6cY/4LpCD/+r/WWWPdn21f4jxSvk1ujZYue0M8rfOrnqy1HuL34vM7edX0HZgciTiNjCkfeADqy2tz43O9pydpuuoa7t/TffovSkPy5s+PRJp6yZW9Wg== X-Complaints-To: Please send complaints to abuse@motzarella.org with full headers NNTP-Posting-Date: Thu, 15 May 2008 15:38:27 +0000 (UTC) In-Reply-To: X-Auth-Sender: U2FsdGVkX1//asUTH+LnoZixGCeRu+3hx1pp20KhFRA3IEkLDW5LJA== Cancel-Lock: sha1:eQdTlE99OtjBGPDpV0EdxxHZPDY= User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) Xref: g2news1.google.com comp.lang.ada:77 Date: 2008-05-15T15:40:27+00:00 List-Id: > I don't think so. It's about elaboration order, and making sure that > variables have a chance to get initialized before they're used. If > you have a package body: > > package body Pak2 is > Counter : Integer := 0; > function Next_Counter return Integer is > begin > Counter := Counter + 1; > return Counter; > end Next_Counter; > end Pak2; > > In Ada semantics, the elaboration of Pak2's body is what initializes > Counter to 0. But if the elaboration of some other package (say Pak3) > used Next_Counter before Pak2's body had a chance to be elaborated, > Counter would be uninitialized and Next_Counter would return garbage. > So it's necessary to ensure that Pak2's body is elaborated before Pak3 > is elaborated, and that's what the Elaborate pragmas are for. > (Without the Elaborate pragmas, Pak2's body might be elaborated first > anyway, but you can't be sure.) > > That's how it works in Ada. I know that GNAT has a big long chapter > in the manual describing how it determines the elaboration order, but > I'm not really familiar with the details. But I'd use the pragmas > anyway; even if GNAT would get things right without them, you may want > to port to a different compiler at a later time. > > In any case, I like Gautier's solution and I wish I'd thought of it; > that avoids the Elaboration issues completely. > > -- Adam Ok thanks for precision, it's clearer for me about elaboration issue now.