From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Generic procedures and their parameters
Date: 06 Sep 2006 09:11:12 -0400
Date: 2006-09-06T09:11:12-04:00 [thread overview]
Message-ID: <wcc1wqpxhqn.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: edmfc8$di4$1@sunnews.cern.ch
Maciej Sobczak <no.spam@no.spam.com> writes:
> But then, you would need to have even such fundamental things like
> Integer belong to Ordered'Class. It's a shaky ground.
Why is that shaky? Integer IS ordered.
> > Regarding Array_Type being implied, it is not. You can have any number of
> > array types based on exactly same combination of index and element types.
> > These types will be different types:
> > type I is ...;
> > type E is ...;
> > type Array1 is array (I range <>) of E;
> > type Array2 is array (I range <>) of E;
>
> > The types Array1 and Array2 are distinct types.
>
> And now I see. I'm still having troubles with the fact that
> "granularity" of type system in Ada can be much smaller than what can be
> achieved with structural differences only.
It's a good thing that Ada allows Array1 and Array2 above to be
different types. But sometimes, structural typing would be better. In
fact, Ada has moved a bit in that direction -- anonymous access types
use structural typing, more or less.
> > The next step would be getting "<" from the element type,
> > which would eliminate a need to have Sort generic.
>
> No, I disagree. There is a place for generic subprograms, otherwise we'd
> have everything in a single hierarchy with Object at the top. It's not a
> coincidence that "other languages" drift towards supporting generics,
> even if they already had such single-rooted hierarchies.
A hierarchy with Object at the top would be a Good Thing, IMHO. Trees
are more aesthetically pleasing than forests. But you're right that you
still need some sort of generic facility, so you can have strongly typed
containers. But I think perhaps we should have generic types
(i.e. parameterized types) rather than generic packages. That's what
discriminants do, but they're severely limited. It would make sense to
have a discriminant that is a type, so you could say:
My_Sequence: Sequence(Element => Integer) := (1, 2, 3);
- Bob
next prev parent reply other threads:[~2006-09-06 13:11 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-06 8:51 Generic procedures and their parameters Maciej Sobczak
2006-09-06 9:43 ` Dmitry A. Kazakov
2006-09-06 12:36 ` Maciej Sobczak
2006-09-06 13:11 ` Robert A Duff [this message]
2006-09-06 14:14 ` Maciej Sobczak
2006-09-06 15:09 ` Dmitry A. Kazakov
2006-09-06 16:35 ` Georg Bauhaus
2006-09-07 7:32 ` Dmitry A. Kazakov
2006-09-07 6:48 ` Georg Bauhaus
2006-09-07 10:19 ` Dmitry A. Kazakov
2006-09-08 9:11 ` Maciej Sobczak
2006-09-08 10:19 ` Dmitry A. Kazakov
2006-09-09 14:49 ` Robert A Duff
2006-09-09 15:34 ` Dmitry A. Kazakov
2006-09-09 23:26 ` Jeffrey R. Carter
2006-09-10 11:49 ` Robert A Duff
2006-09-10 19:43 ` Jeffrey R. Carter
2006-09-06 13:02 ` Robert A Duff
2006-09-06 14:09 ` Dmitry A. Kazakov
2006-09-08 3:35 ` Randy Brukardt
2006-09-08 7:21 ` Dmitry A. Kazakov
2006-09-09 1:29 ` Randy Brukardt
2006-09-09 7:14 ` Dmitry A. Kazakov
2006-09-09 14:32 ` Robert A Duff
2006-09-06 12:56 ` Robert A Duff
2006-09-07 2:47 ` Steve
2006-09-07 7:47 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox