comp.lang.ada
 help / color / mirror / Atom feed
From: "Björn Persson" <spam-away@nowhere.nil>
Subject: Re: questions to generic
Date: Wed, 29 Sep 2004 14:50:11 GMT
Date: 2004-09-29T14:50:11+00:00	[thread overview]
Message-ID: <DYz6d.4461$d5.35002@newsb.telia.net> (raw)
In-Reply-To: <cje105$7lc$02$1@news.t-online.com>

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




      parent reply	other threads:[~2004-09-29 14:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-28 23:58 questions to generic Rick Santa-Cruz
2004-09-29  2:17 ` Georg Bauhaus
2004-09-29  9:58   ` Rick Santa-Cruz
2004-09-29 11:33     ` Georg Bauhaus
2004-09-29 14:52       ` Björn Persson
2004-09-29 17:11         ` Georg Bauhaus
2004-09-29 14:50     ` Björn Persson [this message]
replies disabled

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