comp.lang.ada
 help / color / mirror / Atom feed
* Elaboration of nested generic package.
@ 2003-07-01 20:14 Don Westermeyer
  0 siblings, 0 replies; 21+ messages in thread
From: Don Westermeyer @ 2003-07-01 20:14 UTC (permalink / raw)


Hello,

I'm hoping someone can answer my question.  I would like to know if
using the pragma 'elaborate_body' in a package also also performs
guarantees the elaboration of nested generic packages.

Thanks a lot!


Example:

package Example_Bad is

  -- This is ok.
  pragma elaborate_Body;

  procedure Do_Something;


  


  generic
     type Item_Type is private;
 
  package Nested_package is
    
    -- This is the problem because it this is a nested package.  
    -- The intent is to elaborate instantiations like if this 
    -- was in its own package.
    -- FWIW - This compiles with Rational Ada but not Aonix 
    -- which references LRM:10.1.5(2).  
    -- I would like to get rid of this but don't know if it
    -- is 'safe'. See:
    -- http://www.adaic.org/docs/95style/html/sec_8/8-4-3.html

    pragma Elaborate_Body;
  


    procedure Do_Another_Thing;


  end Nested_Package;



end Example_Bad;



^ permalink raw reply	[flat|nested] 21+ messages in thread
* Re: Elaboration of nested generic package.
@ 2003-07-02  4:13 christoph.grein
  2003-07-08  3:05 ` Don Westermeyer
  0 siblings, 1 reply; 21+ messages in thread
From: christoph.grein @ 2003-07-02  4:13 UTC (permalink / raw)
  To: comp.lang.ada

package Example is

  pragma Elaborate_Body;

  procedure Do_Something;

  generic
    type Item_Type is private;
  package Nested is
    --pragma Elaborate_Body;
    procedure Do_Another_Thing;
  end Nested;

end Example;

There is no need to put pragma Elaborate_Body into the nested generic, because 
the body of Example also holds the body of Nested, and when the body of Example 
is elaborated, the body of Nested is inevitably elaborated as well.

What you cite in the style guide applies only to library generic units (or 
should that be generic library units :-):
http://www.adaic.org/docs/95style/html/sec_8/8-4-3.html




^ permalink raw reply	[flat|nested] 21+ messages in thread
* Re: Elaboration of nested generic package.
@ 2003-07-09  5:21 christoph.grein
  0 siblings, 0 replies; 21+ messages in thread
From: christoph.grein @ 2003-07-09  5:21 UTC (permalink / raw)
  To: comp.lang.ada

Matthew,

I do not see why you think there is a difference whether you instantiate on 
library level or on a nested level:

> with GP;
> pragma Elaborate_All (GP);  --you need this
>
> package body Q is
>    package P is new GP;
> end Q;
>
> See the CLA thread "AQ&S Guidance on pragma Elaborate_Body" which
> occurred in 1997/04 -- particularly the responses from Bob Duff and
> Robert Dewar.
>
> I forget whether you need the pragma for root-level instantiations:
>
> with GP;
> pragma Elaborate_All (GP); --needed?
> package P is new GP;

The pragma says: Elaborate all units that are on the with-tree of the with-ed 
unit (GP) before elaborating the with-ing package (Q resp. P). And the body of 
the generic is needed elaborated before instantiation in any case.

Whether the pragma in the generic spec is of any use, I do not know either and I 
presently do not feel like searching the RM :-(



^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2003-07-17 15:54 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-01 20:14 Elaboration of nested generic package Don Westermeyer
  -- strict thread matches above, loose matches on Subject: below --
2003-07-02  4:13 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
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
2003-07-09  5:21 christoph.grein

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