[log in to unmask] wrote:
> Giles wrote:
...
> It would be interesting to know what it is about Ada Generic Programming
> that is is not done well. I've found it to be extremely useful in my Ada
> programming. Now, to copy a really bad way to implement a good idea, one
> need only look to C++ templates. Here's what gnat.com has to say about Ada
> generics:
Yes, C++ templates are bad. Ada is not that good. Arguing to
irrelevant alternatives is a falacy though. It's simply a rhetorical
trick intended to suggest on one possible alternative to what
you're doing. C++ is not a relevant alternative.
Copying the Ada model in Fortran ignores the number of generic
mechanisms already in Fortran rather than integrating with them.
For example, Fortran already has CLASS(*) generics (not tied to
the hierarchy either, as far as I can tell). Like it or not, that's the
appropriate place to start integrating more features to support
generic programming. A way to set constraints on what * is, for
example, would be a good start. A way to require that two CLASS(*)
arguments must actually be the same type would be another. These
would provide *complete* control over what instances of each
generic existed. It could not create multiple redundant instances of
a procedure with the same type signature simply because instance
names happened to be different. that latter would not even be a
notational possibility: you simply can't write it.
Also, as I recall, Ada is not really what I would call generic. It provides
a way to specify lots of different procedures with a common code body,
not a single procedure (by name or operator) with several different
type signatures. The Ada copying feature can be accomplished with a
rather minimal macro capability (which would have added advantages
in that macros would be useful for more than just parametrized code).
--
J. Giles
"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare
|