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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,23dabf88feae3dba X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!bcklog1.nntp.dca.giganews.com!nntp.megapath.net!news.megapath.net.POSTED!not-for-mail NNTP-Posting-Date: Wed, 21 Jun 2006 15:33:26 -0500 From: "Randy Brukardt" Newsgroups: comp.lang.ada References: <4fssh9F1ena5jU1@individual.net> Subject: Re: Elaboration worries Date: Wed, 21 Jun 2006 15:34:12 -0500 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 Message-ID: <8KOdnYaLZJaLMATZnZ2dnUVZ_tydnZ2d@megapath.net> NNTP-Posting-Host: 64.32.209.38 X-Trace: sv3-6cx3Ce8p+qJHaCmuvR3OEAUxkfL4bOM1n42xsMf91nS1HZ2PvZyNcaryexF9fzeKfNoEmWpCJQOZMaW!yzA65jOA0aCw26KP0wA7kjX2olYsCMIQ9QdoMfzg7ICazHmYNCW2plNvLn/KgcPfmD1DhDToHpFh!gv/34hxn8JxWPg== X-Complaints-To: abuse@megapath.net X-DMCA-Complaints-To: abuse@megapath.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32 Xref: g2news2.google.com comp.lang.ada:4881 Date: 2006-06-21T15:34:12-05:00 List-Id: "Alex R. Mosteo" wrote in message news:4fssh9F1ena5jU1@individual.net... ... > From past discussions and from reading an old article of Mr. Dewar, my rule > of thumb is that you should > > a) make your package Pure. > b) if not possible, make it Preelaborate. > c) if not possible, put an Elaborate_Body in the spec. Unfortunately, this rule of thumb is wrong (you probably got it from reading the old article). Adacore later discovered that having Elaborate_Body in a spec does not eliminate elaboration problems, and their modern versions of GNAT don't make any recommendation for this. We were bitten rather badly by this with Claw (which followed your list of recommendations quite closely). I forget the exact reason that Elaborate_Body doesn't work, but the effect is that you can't count on it to eliminate elaboration problems completely. Effectively, if you do much of anything at elaboration time, you'll need Elaborate_All in the clients for any packages that aren't at least Preelaborate. There is nothing whatsoever that can be done for the service packages that prevents that. (It's really a flaw in Ada, but one that cannot be fixed without radical surgery and incompatibilities -- not an option these days). My personal rule of thumb is: (a) make your package Preelaborate if possible (Pure is so limited that no real packages ever qualify) -- but this is usually impossible because I/O and Calendar aren't Preelaborate. Which means that you can't trace or log a Preelaborate package (well, there *is* one way to do it, but it adds runtime overhead); (b) if not (a), try to avoid doing anything at elaboration time other than use language-defined packages; (c) if not (b), then you have to add Elaborate_All for anything used at elaboration time. (c) usually happens when you have generic instantiations at the library level, or you declare controlled objects at the library level. The latter can be avoided, the former obviously can't. I've long since given up running code (the 'begin' part of a package body) at elaboration time; there always seems to be some reason that you have initialization dependencies that aren't encoded in the elaboration order (for instance, the need to load parameters from the registry or a configuration file before starting a subsystem). I use appropriate initialization routines (and often checks for calls to other routines in the package that the initialization has been properly called). Hope this helps. Randy.