comp.lang.ada
 help / color / mirror / Atom feed
* Cannot implement with an instantiation?!
@ 2007-10-25 17:34 amado.alves
  2007-10-25 17:41 ` Adam Beneschan
  0 siblings, 1 reply; 2+ messages in thread
From: amado.alves @ 2007-10-25 17:34 UTC (permalink / raw)


Ada is being very bad to me. She does not let me instantiate a generic
procedure Generic_Connect nested in a generic package body
Generic_Graphs. Is she in any reason? And how do I make things right?
Thanks a lot.

generic
   ...
package Generic_Graphs is
   ...
   procedure Connect
     (Digraph : in out Digraph_Type;
      From, To : Node_Array);
   ...
end;


package body Generic_Graphs is
   ...

   generic
      ...
   procedure Generic_Connect
     (Digraph : in out Digraph_Type;
      From, To : Node_Array);

   procedure Generic_Connect
     (Digraph : in out Digraph_Type;
      From, To : Node_Array) is
   begin
      ...
   end;

   procedure Connect
     (Digraph : in out Digraph_Type; -- <== GNAT complains here saying
that a
      From, To : Node_Array)         -- formal part is not allowed in
an instantiation
   is new Generic_Connect (True);

   ...
end;


That's ok.

But if the offending part is removed then GNAT says that it conflicts
with the declaration in the package spec.

This is silly. I cannot implement an exported entity with a private
instantiation?!

And then if I move the generic procedure declaration and the
instantiation to the spec then it complains that the instantiation
must be done after the body is visible!

Help!!!




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

* Re: Cannot implement with an instantiation?!
  2007-10-25 17:34 Cannot implement with an instantiation?! amado.alves
@ 2007-10-25 17:41 ` Adam Beneschan
  0 siblings, 0 replies; 2+ messages in thread
From: Adam Beneschan @ 2007-10-25 17:41 UTC (permalink / raw)


On Oct 25, 10:34 am, amado.al...@gmail.com wrote:
> Ada is being very bad to me. She does not let me instantiate a generic
> procedure Generic_Connect nested in a generic package body
> Generic_Graphs. Is she in any reason? And how do I make things right?

Renaming-as-body.  See below.


> Thanks a lot.

You're welcome!

> generic
>    ...
> package Generic_Graphs is
>    ...
>    procedure Connect
>      (Digraph : in out Digraph_Type;
>       From, To : Node_Array);
>    ...
> end;
>
> package body Generic_Graphs is
>    ...
>
>    generic
>       ...
>    procedure Generic_Connect
>      (Digraph : in out Digraph_Type;
>       From, To : Node_Array);
>
>    procedure Generic_Connect
>      (Digraph : in out Digraph_Type;
>       From, To : Node_Array) is
>    begin
>       ...
>    end;
>
>    procedure Connect
>      (Digraph : in out Digraph_Type; -- <== GNAT complains here saying
> that a
>       From, To : Node_Array)         -- formal part is not allowed in
> an instantiation
>    is new Generic_Connect (True);

    procedure Generic_Connect_Inst is new Generic_Connect (True);
    procedure Connect (Digraph : in out Digraph_Type;
                       From, To : Node_Array)
        renames Generic_Connect_Inst;

                             -- Adam




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

end of thread, other threads:[~2007-10-25 17:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-25 17:34 Cannot implement with an instantiation?! amado.alves
2007-10-25 17:41 ` Adam Beneschan

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