comp.lang.ada
 help / color / mirror / Atom feed
From: "Matthew Heaney" <matthew_heaney@acm.org>
Subject: Re: Extended revelation
Date: 2000/01/31
Date: 2000-01-31T00:00:00+00:00	[thread overview]
Message-ID: <u4jl4.1635$gC3.76670@newsread1.prod.itd.earthlink.net> (raw)
In-Reply-To: 87446a$h6u$1@nnrp1.deja.com

In article <87446a$h6u$1@nnrp1.deja.com> , Jean-Marc Bourguet 
<bourguet@my-deja.com>  wrote:

> I think indeed you have not understood what I want to do. What I really
> want is something like modula-3 partial revelation: one package
> providing multiples interface. In Ada95, a package has two interfaces,
> one for the general public, one for his children. What I want is
> multiple public interfaces. Until now, using child package has
> permetted me to do this cleanly and here is the first example I come
> with where I do not find a clean solution in Ada.

Indeed I still don't know what you want to do.  (Perhaps this is because
I am unfamiliar with Modula-3.)

Will static polymorphism work?

package P1 is

  type T is private;

  procedure Op (O : in out T);
...
end P1;

package P2 is

  type T is private;

  type Op (O : in out T);
...
end P2;


If you want "multiple public interfaces," then why not implement
"multiple public interfaces"?  That is, different abstractions with
identical public parts.

If you want to statically bind to the "virtual abstraction" reified by
P1 and P2, then use library-level package renaming:

with P1;
package P renames P1;

or

with P2;
package P renames P2;

Clients of "abstract" package P don't know or care which "concrete"
package is used to implement P.

That's how to handle it on the supplier side.  Another way is to use
"implementation inheritance," and import the type as generic formal
parameters:

generic
  type T is private;
  with procedure Op (O : in out T) is <>;
package Generic_Client is ...;

To make a client, you just supply any type with a matching profile:

with P1; use P1;
package Client is new Generic_Client (T);

or

with P2; use P2;
package Client is new Generic_Client (T);


But I'm only guessing what it is you're trying to do.  Perhaps if you
provide a small amount of code, then we can give you more specific help
to solve your problem.




  reply	other threads:[~2000-01-31  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-01-31  0:00 Extended revelation Jean-Marc Bourguet
2000-01-31  0:00 ` Jean-Marc Bourguet
2000-01-31  0:00   ` Matthew Heaney [this message]
2000-01-31  0:00     ` Vladimir Olensky
2000-02-01  0:00   ` Richard D Riehle
2000-01-31  0:00 ` Mark Lundquist
2000-01-31  0:00 ` Matthew Heaney
replies disabled

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