Re: Generic procedures and their parameters
- From: Robert A Duff <bobduff@xxxxxxxxxxxxxxxxxxxx>
- Date: 06 Sep 2006 09:11:12 -0400
Maciej Sobczak <no.spam@xxxxxxxxxxx> 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
.
- Follow-Ups:
- Re: Generic procedures and their parameters
- From: Maciej Sobczak
- Re: Generic procedures and their parameters
- References:
- Generic procedures and their parameters
- From: Maciej Sobczak
- Re: Generic procedures and their parameters
- From: Dmitry A. Kazakov
- Re: Generic procedures and their parameters
- From: Maciej Sobczak
- Generic procedures and their parameters
- Prev by Date: Re: Generic procedures and their parameters
- Next by Date: Coverage analysis on Windows
- Previous by thread: Re: Generic procedures and their parameters
- Next by thread: Re: Generic procedures and their parameters
- Index(es):
Relevant Pages
|
Loading