Re: limited types (Was: Records that could be arrays)



On 27 Feb 2006 08:52:23 -0800, Matthew Heaney wrote:

Dmitry A. Kazakov wrote:

1. Passing as a parameter

Just pass a cursor:

I don't see how a constraint imposed on elements can propagate to the
cursor.

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. Whatever you do, the polymorphism can come only from outside,
like in the case of a tagged formal parameter, or as a type inheritance in
the declarative part of a generic package. So generics are completely
irrelevant to the discussion about the design of constructors and the types
system.

2. Copying

while (Has_Element (C) loop
Put_Element_Somewhere (Element (C);
end loop;

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, because barrels and boxes
never meet in the production line. But they can on a container ship. And
their elements do in someone's stomach.

4. Slicing

Just use a cursor pair:

Do_Something (C1, C2); -- half-open range

Huh, what about a submatrix? The main diagonal of? And, BTW, I don't do
anything I want to get a new container.

[...]
Do_Something (C1, C2);
Compare (C1, C2);

Same as above.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.



Relevant Pages

  • Re: Ada.Containers.Indefinite_Ordered_Maps of gcc 4.0.1 has bug ?
    ... Empty_Map: constant Map; ... No_Element: constant Cursor; ... function Length (Container: Map) return Count_Type; ... pragma Inline; ...
    (comp.lang.ada)
  • Re: More Generics warnings.
    ... chance to ruminate about generics in the hopes of shedding some light ... is something we deal with regularly, eg., with List: a List reference ... The wildcard constraint can be reduced from "Object" to some more ... promoting assignments are valid: ...
    (comp.lang.java.programmer)
  • Re: Compiler Error CS0702
    ... So I see no reason for the spec to ... I have also pointed out that the specification does specifically disallow the use of System.Enum as a constraint, contrary to your statements that it doesn't. ... As is the case for any value type, assigning an instance of the value type to a reference type variable requires boxing. ... generics treat value type parameters differently from reference type parameters. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Run-time accessibility checks
    ... No I made it having same interface, ... container, *because* it is of a different type. ... The cursor is the index in the model you have here. ... to be used to achieve the goal, and secondly return by reference is marked ...
    (comp.lang.ada)
  • Re: Generics with multiple constrains
    ... It seems that I can't use generics in my example, even though I want to, ... looking at this very narrowly in terms of generic constraint lists. ... C++ to VB Converter ... C++ to Java Converter ...
    (microsoft.public.dotnet.languages.csharp)