comp.lang.ada
 help / color / mirror / Atom feed
* Generic type parameters
@ 1999-06-14  0:00 dommo1234
  1999-06-15  0:00 ` Matthew Heaney
  0 siblings, 1 reply; 3+ messages in thread
From: dommo1234 @ 1999-06-14  0:00 UTC (permalink / raw)


This query regards generic packages, and their instantiation with some
actual type.

OK, I have a generic package that requires to be instantiated with a
number of different types. The generic has a number of primative methods
that need to return either the type that the generic package was
instantiated with, an access to the type, or a constant access to the
type, as in the example below :-

generic
    type TypeX is private;
package Example is
    function One(..) return TypeX;
    function Two(..) return TypeX_A;
    function Three(..) return TypeX_AC;
end Example;

... where 'TypeX_A' needs to be "access all TypeX"
    and   'TypeX_AC' needs to be "access constant TypeX".

The problem is that if I delcare the two types 'TypeX_A' and 'TypeX_AC'
inside the generic, then any code containing variables that catch the
values of functions 'Two' and 'Threee' inside my generic must be of type
<generic inst>.Type_A etc. This is not very readable or convenient!

The only (not so sensible) solution I can think of is provide the
generic with 3 formal parameters, ie. TypeX, TypeX_A and TypeX_AC ....

Does anyone have a neater solution to this??

Thanks,
Dom.



Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-06-15  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-06-14  0:00 Generic type parameters dommo1234
1999-06-15  0:00 ` Matthew Heaney
1999-06-15  0:00   ` dommo1234

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