comp.lang.ada
 help / color / mirror / Atom feed
From: akonstan@news.cs.columbia.edu (Alexander V. Konstantinou)
Subject: Re: Extending A Generic Signature Package
Date: 1997/03/18
Date: 1997-03-18T00:00:00+00:00	[thread overview]
Message-ID: <5gn90o$gm1@sutton.cs.columbia.edu> (raw)
In-Reply-To: E78yEu.15.0.-s@inmet.camb.inmet.com


Tucker Taft (stt@houdini.camb.inmet.com) wrote:
: david scott gibson (dgibson@thalamus.cis.ohio-state.edu) wrote:

: : Hi.  Is any way in Ada to extend a generic signature package?  For
: : example, if I had the signature package Base_Interface:

[snip]

: Well, I'm not exactly sure what is your goal, but the following
: might satisfy you:

:     with Base_Interface;
:     generic
:         with package Base is new Base_Interface(<>);
:         with procedure Op2(x : in out Base.T);
:     package Extended_Interface is end;

: Given any instantiation of Base_Interface and an appropriate
: "Op2", you can create an instantiation of Extended_Interface as follows:

:     with Extended_Interface;
:     with My_Base;
:     with ...appropriate other stuff...
:     package Extended is new Extended_Interface(My_Base, My_Op2);

Unfortunately, with the above code one is either forced to
reexport the Base_Interface operations in Extended_Interface
or the user has to "use" all the new generic rackage
instances (i.e. use My_Extended; use My_Extended.Base;).
If you don't like "use" clauses, then you need to remember
where in the hierarchy an operation is defined.

OO people will tell you to use inheritance, but there is
really no reason to pay for the overhead when your abstraction
can be served by a compile-time check.

Anyone know how to do this without restricting writability?
I have ended up many times repeating the operations in
the "Extended" to make use easier.


-- 
Alexander V. Konstantinou              http://www.cs.columbia.edu/~akonstan/
akonstan@cs.columbia.edu               akonstan@acm.org




  reply	other threads:[~1997-03-18  0:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-03-17  0:00 Extending A Generic Signature Package david scott gibson
1997-03-18  0:00 ` Tucker Taft
1997-03-18  0:00   ` Alexander V. Konstantinou [this message]
1997-03-21  0:00     ` Geert Bosch
1997-03-21  0:00       ` Brian Rogoff
1997-03-22  0:00         ` Robert A Duff
1997-03-21  0:00 ` Jon S Anthony
1997-03-21  0:00   ` david scott gibson
1997-03-22  0:00     ` Robert A Duff
1997-03-22  0:00 ` Jon S Anthony
1997-03-21  0:00   ` david scott gibson
1997-03-22  0:00     ` Robert A Duff
1997-03-25  0:00 ` Jon S Anthony
replies disabled

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