Re: limited types (Was: Records that could be arrays)
- From: "Dmitry A. Kazakov" <mailbox@xxxxxxxxxxxxxxxxx>
- Date: Tue, 28 Feb 2006 22:03:37 +0100
On 28 Feb 2006 11:58:11 -0800, Matthew Heaney wrote:
Dmitry A. Kazakov wrote:
On 28 Feb 2006 09:24:35 -0800, Matthew Heaney wrote:
I still don't see CS.
I wrote the declaration wrong; it should have been:
generic
type ET is private; --or: type ET (<>) is limited private;
type CT is private; --cursor type
with function E (C : CT) return ET is <>;
procedure Generic_Algorithm (C1, C2 : CT);
The cursor pair [C1, C2) describes a range of elements. It might be
the entire range of elements in the container, or just a subrange. The
algorithm doesn't care.
But still S <: T does not imply CS <: CT.
BTW, if I had CS, would need not to instantiate Generic_Algorithm once
more.
(I assume "CS" means "container of element type S, and S derives from
type T.")
Yes and CS should be a subtype of CT, so that CS could be passed as an "in"
where CT is expected. It also could be as an "out", but then with a chance
of Constraint_Error at run-time.
As far as generic algorithms are concerned, it doesn't matter that type
S derives from type T. That's what "generic algorithm" means.
It means "works on a set of types." Generics are only one [weakest] form of
polymorphism.
And yes, you have to instantiate the algorithm twice, since the cursor
types come from different instantiations of some generic container
package.
That is the whole point. BTW, you will need to instantiate it more than
twice for cross combinations, like when C1 is CS and C2 is CT. It
geometrically explodes.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.
- References:
- limited types (Was: Records that could be arrays)
- From: Thierry Bernier
- Re: limited types (Was: Records that could be arrays)
- From: Randy Brukardt
- Re: limited types (Was: Records that could be arrays)
- From: Dmitry A. Kazakov
- Re: limited types (Was: Records that could be arrays)
- From: Matthew Heaney
- Re: limited types (Was: Records that could be arrays)
- From: Dmitry A. Kazakov
- Re: limited types (Was: Records that could be arrays)
- From: Matthew Heaney
- Re: limited types (Was: Records that could be arrays)
- From: Dmitry A. Kazakov
- Re: limited types (Was: Records that could be arrays)
- From: Matthew Heaney
- Re: limited types (Was: Records that could be arrays)
- From: Dmitry A. Kazakov
- Re: limited types (Was: Records that could be arrays)
- From: Georg Bauhaus
- Re: limited types (Was: Records that could be arrays)
- From: Dmitry A. Kazakov
- Re: limited types (Was: Records that could be arrays)
- From: Matthew Heaney
- Re: limited types (Was: Records that could be arrays)
- From: Dmitry A. Kazakov
- Re: limited types (Was: Records that could be arrays)
- From: Matthew Heaney
- Re: limited types (Was: Records that could be arrays)
- From: Dmitry A. Kazakov
- Re: limited types (Was: Records that could be arrays)
- From: Matthew Heaney
- Re: limited types (Was: Records that could be arrays)
- From: Dmitry A. Kazakov
- Re: limited types (Was: Records that could be arrays)
- From: Matthew Heaney
- limited types (Was: Records that could be arrays)
- Prev by Date: New release of the PragmAda Reusable Components
- Next by Date: Re: limited types
- Previous by thread: Re: limited types (Was: Records that could be arrays)
- Next by thread: Re: limited types
- Index(es):
Relevant Pages
|
|