comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Generic library design
Date: Fri, 6 Apr 2018 21:32:28 -0500
Date: 2018-04-06T21:32:28-05:00	[thread overview]
Message-ID: <pa9ajt$oh$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: 1d9faa0f-d3d7-4eb4-aa88-b50ed1e9aac3@googlegroups.com


"Marius Amado-Alves" <amado.alves@gmail.com> wrote in message 
news:1d9faa0f-d3d7-4eb4-aa88-b50ed1e9aac3@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.


  reply	other threads:[~2018-04-07  2:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-06 13:22 Generic library design Marius Amado-Alves
2018-04-07  2:32 ` Randy Brukardt [this message]
2018-04-12  8:21   ` Marius Amado-Alves
2018-04-12 10:23   ` Marius Amado-Alves
2018-04-12 15:41     ` Dan'l Miller
2018-04-12 15:32   ` Dan'l Miller
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox