comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <Stephe.Leake@nasa.gov>
Subject: Re: A good way to name instantiated children?
Date: 20 Jun 2003 17:06:28 -0400
Date: 2003-06-20T21:06:49+00:00	[thread overview]
Message-ID: <u65n0h31n.fsf@nasa.gov> (raw)
In-Reply-To: bcvad2$nbrf4$1@ID-77047.news.dfncis.de

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:

> Hi!
> 
> Let we have a chain of generic packages:
> 
> A.B.C.D...
> 
> Let the root A have a generic parameter, say,
> 
>    type Number is private;
> 
> Now, I want to instantiate all packages of the chain with Number => Float. 
> The problem i,s how to name the children?
> 
>    package Float_A is new A (Float);
> 
> is fine, but the children cannot be named Float_A.B.C.D:
> 
>    with Float_A;
>    with A.B;
>    package Float_A.B is new Float_A.B; -- Error
> 
> (generic A.B contaminates the name space of Float_A). 
> 
> Float_A.Float_B.Float_C.Float_D looks awful.
> 
> Any ideas?

I solve this by prefixing Gen_ to the generic package names:

generic
    type Number is private;
package Gen_A is ...

generic
package Gen_A.Gen_B is ...

Then the instantiations can be:

with Gen_A;
package Float_A is new Gen_A (Float);

with Gen_A.Gen_B;
package Float_A.B is new Float_A.Gen_B;

Yes, the Gen_A.Gen_B.Gen_C.Gen_D is a little ugly. But the
instantiation names are nice, which is more important. And it makes it
clear from the package name whether the package is generic or not,
which is also helpful.

-- 
-- Stephe



  reply	other threads:[~2003-06-20 21:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-20 15:51 A good way to name instantiated children? Dmitry A. Kazakov
2003-06-20 21:06 ` Stephen Leake [this message]
2003-06-21  6:48   ` Simon Wright
2003-06-21 19:43     ` Jeffrey Carter
2003-06-23 13:39       ` Stephen Leake
2003-06-21  7:12   ` Dmitry A. Kazakov
replies disabled

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