Re: limited types (Was: Records that could be arrays)
- From: Georg Bauhaus <bauhaus@xxxxxxxxxxxxx>
- Date: Mon, 27 Feb 2006 22:40:18 +0100
Dmitry A. Kazakov wrote:
The question Georg asked was: where typed containers of elements of related
types might themselves appear related. The number of cases is huge.
Generics fundamentally cannot help here, they aren't dynamically
polymorphic.
But then wouldn't you again be mixing apples and herrings?
type APPLE_CONTAINER is new CONTAINER with null record;
-- specializes in apples, only
type HERRING_CONTAINER is new CONTAINER with null record;
-- specializes in herrings, only
x: access CONTAINER'class := ...;
x.insert(an_apple); -- right or wrong? compile time?
It is dynamic typing. The constraint check would happen at run-time. Too
late. You just have tossed a stinking herring in a jug apple cider...
3. Merging
You'll need to define a relational operator over your element type, but
then you can say:
Merge (C1.First, C2.First);
Same as above. I don't mix herrings and apples,
In fact, herrings with little pieces of apple aren't
that unusual, add onions and mayonnaise and you are
almost set - not everyone's taste, maybe. :-) Seriously,
wouldn't type-forcing containers be in the way of
composition?
How do you make a vector of doughnuts with different
toppings? Something like
zip(doughnuts.first, toppings.first);
seems reasonable to me.
.
- Follow-Ups:
- Re: limited types (Was: Records that could be arrays)
- From: Dmitry A. Kazakov
- Re: limited types (Was: Records that could be arrays)
- 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
- limited types (Was: Records that could be arrays)
- Prev by Date: Re: limited types (Was: Records that could be arrays)
- Next by Date: Re: limited types (Was: Records that could be arrays)
- Previous by thread: Re: limited types (Was: Records that could be arrays)
- Next by thread: Re: limited types (Was: Records that could be arrays)
- Index(es):
Relevant Pages
|
|