comp.lang.ada
 help / color / mirror / Atom feed
* [Q]: Generic subprogram instantiation
@ 1996-07-05  0:00 Michael Bartz
  1996-07-06  0:00 ` Robert A Duff
  1996-07-06  0:00 ` Robert Dewar
  0 siblings, 2 replies; 5+ messages in thread
From: Michael Bartz @ 1996-07-05  0:00 UTC (permalink / raw)




I am trying to create an instantiated subprogram within a declarative
block of a main subprogram.  I want to pick the particular instantiation
at run-time so I put the declarative block within one of the choices
within a case statement.  I am instatiating the subprograms so that each
particular subprogram can pick up some instantiated packages unique to
each particular choice (of the case statement).

The problem is that GNAT flags this arrangement with the following:

main.adb:26:09: "sub_main" is hidden within declaration of instance
main.adb:33:09: "sub_main" is hidden within declaration of instance

On surface inspection, I am not sure I understand exactly why the compiler
has flagged this? 

Can anyone explain this error message for me in the context of the program
fragments below?

I will send full sources if required.




--main.adb
with all_field_types; use all_field_types;
with sub_main;
with field;
with text_io; use text_io;

procedure main is

  N : Positive := 8;

  package int_io is new integer_io(Integer);

begin

  case N is
    when 8 =>
      declare
        package galois is new Field(GF8_types);
        procedure sub_main is new sub_main(galois);
      begin
        sub_main(N);
      end;
    when 16 =>
      declare
        package galois is new Field(GF16_types);
        procedure sub_main is new sub_main(galois);
      begin
        sub_main(N);
      end;
    when others =>
      null;

  end case;

end main;

--sub_main.adb
procedure sub_main(Z:Integer) is
  use local_field;
  X : Field_Element := 1;
  A : Boolean;

begin

  A := Value(0);

end sub_main;

--sub_main.ads
with field;
generic
  with package local_field is new field (<>);
  procedure sub_main(Z:Integer);

-- 
Michael Bartz                            Proud Member of Team Ada(95)
The University of Memphis

m-bartz@memphis.edu




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

end of thread, other threads:[~1996-07-11  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-07-05  0:00 [Q]: Generic subprogram instantiation Michael Bartz
1996-07-06  0:00 ` Robert A Duff
1996-07-11  0:00   ` Tucker Taft
1996-07-11  0:00     ` Robert A Duff
1996-07-06  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