Re: questions to generic
From: Björn Persson (spam-away_at_nowhere.nil)
Date: 09/29/04
- Next message: Björn Persson: "Re: questions to generic"
- Previous message: Frank: "Re: Ada and Robotics (for fun)?"
- Maybe in reply to: Georg Bauhaus: "Re: questions to generic"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 29 Sep 2004 14:50:11 GMT
Rick Santa-Cruz wrote:
> And how and where do I have to instantiate the procedure then?
For example:
procedure Gen_Test_Client is
generic
type Element is private;
procedure Gen_Proc(El: Element);
procedure Gen_Proc(El: Element) is
begin
null;
end Gen_Proc;
procedure Natural_Proc is new Gen_Proc(Natural);
procedure Character_Proc is new Gen_Proc(Character);
begin -- Gen_Test_Client
Natural_Proc(5);
Character_Proc('X');
end Gen_Test_Client;
> So is it this way correct:
> package Pack1 is
> generic
> type Element is private;
> package Child_Pack is
> procedure Proc(El: Element);
> end Child_Pack;
> end Pack1;
Strictly speaking, that's a subpackage. A child package is specified
separately. (With Gnat it will be in its own file.)
package Parent is
package Subpackage is
end Subpackage;
end Parent;
package Parent.Child_Package is
end Parent.Child_Package;
> with Pack1; -- by the way when I write here: with Pack1.Child_Pack; I get a
> compilation-error. Why?
When you write "with Pack1;" you get access to everything in Pack1,
including subpackages. For a child package you'd have to write "with
Parent.Child_Package;".
--
Björn Persson PGP key A88682FD
omb jor ers @sv ge.
r o.b n.p son eri nu
- Next message: Björn Persson: "Re: questions to generic"
- Previous message: Frank: "Re: Ada and Robotics (for fun)?"
- Maybe in reply to: Georg Bauhaus: "Re: questions to generic"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|