comp.lang.ada
 help / color / mirror / Atom feed
* Elaboration of nested packages.
@ 1997-06-18  0:00 Bill Keen
  1997-06-19  0:00 ` Robert A Duff
  1997-06-20  0:00 ` Robert Dewar
  0 siblings, 2 replies; 5+ messages in thread
From: Bill Keen @ 1997-06-18  0:00 UTC (permalink / raw)



The following piece of code expresses the essence of a problem I am
having in an Ada project using Ada83 and an old Alsys cross compiler. I
brought the fragment home to exercise it using GNAT 3.07 on DOS, and I
am more confused than ever.

with Ada.text_io; use Ada.text_io;
procedure P is
  package OP is
    generic
    package IG is
    end IG;
  end OP;
  package PI is new OP.IG; -- Is this ok?
  package body OP is
    package body IG is
    begin
      put_line("Elaborated body IG");
    end;
  begin
    put_line("Elaborated body OP");
  end;
begin
  put_line("Main program");
end P;

When I run the program it generates I get:
Elaborated body OP
Main program

If I move the instantiation of OP.IG to below the body of OP the result
seems quite logical as it prints:
Elaborated body OP
Elaborated body IG
Main program

The first case baffles me. Does it never instantiate IG? 

The investigation started when I thought in Ada83 this should raise
Program_error because of access before elaboration. I haven't run this
exact example on the Alsys compiler yet, but similar examples compile
and run ok. The LRM(83) 11.1-7 says (of Program_error) "This exception
is raised upon an attempt ... to elaborate a generic instantiation if
the body of the corresponding unit has not been elaborated." Surely the
instantiation of OP.IG qualifies.

I can't find a statement corresponding to 11.1-7 in the Ada95 RM. Has
the meaning of program_error changed in Ada95?

-- 
Bill Keen




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

end of thread, other threads:[~1997-06-22  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-06-18  0:00 Elaboration of nested packages Bill Keen
1997-06-19  0:00 ` Robert A Duff
1997-06-20  0:00 ` Robert Dewar
1997-06-22  0:00   ` Bill Keen
1997-06-22  0:00     ` Robert Dewar

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