"Marius Amado-Alves" <
amado...@gmail.com> wrote in message
news:1d9faa0f-d3d7-4eb4...@googlegroups.com...
...
> Consider the running example: why is Ada.Numerics.Generic_Complex_Arrays
> parametrized by packages, instead of just a Real type and then instantiate
> the
> packages intarnally?
When you do that, you are insisting on a new complex type with each
instantiation of the complex arrays package. But perhaps you want one
complex type and several complex array instantiations. (That makes more
sense when the index subtype is a parameter to the generic; one certainly
might want arrays indexed by different types.)
> And are compilers smart enough to merge identical instances w.r.t.
>to their generic arguments? Maybe with help of qualification pragmas
>telling there is no state?
Depends on the compiler. Janus/Ada shares all generic bodies (with all of
the overhead that entails), so it is an extreme version. Other compilers
don't try to share anything. Some are somewhere in the middle.
Note that argubly sharing based on generic parameters is (was?) patented and
not usable by implementers without legal issues.
> No need to answer to all questions at once:-)
OK, the above is enough. :-)
Randy.