comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <rieachus@attbi.com>
Subject: Re: Elaboration of nested generic package.
Date: Thu, 10 Jul 2003 01:35:44 GMT
Date: 2003-07-10T01:35:44+00:00	[thread overview]
Message-ID: <3F0CC2D1.10904@attbi.com> (raw)
In-Reply-To: 5437fafb.0307091710.5cb4b0eb@posting.google.com

Don Westermeyer wrote:

> Usually I do use pragma Elaborate_All for every dependancy anyway
> since one does not have control over every software module developed. 
> Using it is always safer and causes no penalties that I know of
> (assuming the design stays clear of mutual dependancies).

This is silly.  The reason that Ada doesn't automagically assume 
Elaborate_Body or Elaborate_All, is that there is a better assumption. 
The implementation knows the potential elaboration issues and is 
encouraged to chose one that cannot result in Program_Error.

So why then do the pragmas exist?  Because it is possible to write 
programs with several different legal elaboration orders, and it may be 
either impossible (you can imbed an instance of the Halting Problem) for 
the compiler to choose the intended elaboration order, or the "correct" 
elaboration order can depend on something read in at execution time.  In 
either of those two cases, the compiler can tell the programmer, "If 
you're so smart, you tell me how to do it."

But in general, if the compiler can't figure it out, the programmer is 
very unlikely to have a decent answer in mind.

Using pragma Elaborate, Elaborate_All, or Elaborate_Body 
indiscriminantly can only make the Ada compiler's job harder.  There are 
two exceptions though.  If you know that the subprograms declared in a 
package are used before the main program is elaborated, by all means use 
Elaborate_All.  Also, if you have a package that would not otherwise 
require a body, pragma Elaborate_Body can insure that a body is 
required.  Otherwise you can get embarrassed if the body is not updated 
when the specification is changed.

-- 

                                                        Robert I. Eachus

�In an ally, considerations of house, clan, planet, race are 
insignificant beside two prime questions, which are: 1. Can he shoot? 2. 
Will he aim at your enemy?� -- from the Laiden novels by Sharon Lee and 
Steve Miller.




  reply	other threads:[~2003-07-10  1:35 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-02  4:13 Elaboration of nested generic package christoph.grein
2003-07-08  3:05 ` Don Westermeyer
2003-07-08 17:46   ` Matthew Heaney
2003-07-10  1:10     ` Don Westermeyer
2003-07-10  1:35       ` Robert I. Eachus [this message]
2003-07-10  4:51         ` Robert I. Eachus
2003-07-10  6:58           ` Jean-Pierre Rosen
2003-07-10 15:08             ` Robert I. Eachus
2003-07-11 21:26             ` Robert A Duff
2003-07-10 14:12         ` Matthew Heaney
2003-07-10 15:39           ` Robert I. Eachus
2003-07-11 21:41           ` Robert A Duff
2003-07-14 18:35             ` Matthew Heaney
2003-07-15 17:19               ` Randy Brukardt
2003-07-16 15:24                 ` Matthew Heaney
2003-07-17  2:08                   ` Randy Brukardt
2003-07-17 15:54                     ` Richard Riehle
2003-07-10 15:03         ` Don Westermeyer
2003-07-10 15:45       ` Matthew Heaney
  -- strict thread matches above, loose matches on Subject: below --
2003-07-09  5:21 christoph.grein
2003-07-01 20:14 Don Westermeyer
replies disabled

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