comp.lang.ada
 help / color / mirror / Atom feed
* Getting types from a generic container in Ada?
@ 2015-07-26  6:08 EGarrulo
  2015-07-26 17:36 ` Georg Bauhaus
  0 siblings, 1 reply; 2+ messages in thread
From: EGarrulo @ 2015-07-26  6:08 UTC (permalink / raw)


I would like to write a generic package that operates on standard containers. Such package would need access to various properties of a container, and I would like to get them from the container itself, instead of passing them as parameters for the generic package.  In other words, I would like to write something like:


generic
   type Container_Type is private;
package My_Package is
   procedure My_Function (Container : in out Container_Type; 
                          Element   :        Container_Type.Element_Type);
end My_Package;


Is this possible?  Thank you.

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

* Re: Getting types from a generic container in Ada?
  2015-07-26  6:08 Getting types from a generic container in Ada? EGarrulo
@ 2015-07-26 17:36 ` Georg Bauhaus
  0 siblings, 0 replies; 2+ messages in thread
From: Georg Bauhaus @ 2015-07-26 17:36 UTC (permalink / raw)


On 26.07.15 08:08, EGarrulo wrote:
> I would like to write a generic package that operates on standard containers. Such package would need access to various properties of a container, and I would like to get them from the container itself, instead of passing them as parameters for the generic package.  In other words, I would like to write something like:
>
>
> generic
>     type Container_Type is private;
> package My_Package is
>     procedure My_Function (Container : in out Container_Type;
>                            Element   :        Container_Type.Element_Type);
> end My_Package;
>
>
> Is this possible?  Thank you.

Reexport of generic parameters is not part of the design. It is
still possible to write some generic algorithms (using formal
packages, or signatures, or iterators, to the extent permitted
by design and non-recursive Ada templates.)

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

end of thread, other threads:[~2015-07-26 17:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-26  6:08 Getting types from a generic container in Ada? EGarrulo
2015-07-26 17:36 ` Georg Bauhaus

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