comp.lang.ada
 help / color / mirror / Atom feed
* Generic library design
@ 2018-04-06 13:22 Marius Amado-Alves
  2018-04-07  2:32 ` Randy Brukardt
  0 siblings, 1 reply; 6+ messages in thread
From: Marius Amado-Alves @ 2018-04-06 13:22 UTC (permalink / raw)


Hello hive mind. Designing a few generic libraries involving real and complex number types and arrays thereof. Undecided as to the type of generic parameter(s). Namely:

When should the parameter(s) be the base real type like (examples drawn from the standard, please extrapolate)

   generic
      type Real is digits <>;
   package Ada.Numerics.Generic_Real_Arrays is
   ...

with the necessary sidekicks e.g. Generic_Elementary_Functions instantiated internally,

when should it be one or more packages like 

   generic
      with package Real_Arrays   is new
         Ada.Numerics.Generic_Real_Arrays   (<>);
      use Real_Arrays;
      with package Complex_Types is new
         Ada.Numerics.Generic_Complex_Types (Real);
      use Complex_Types;
   package Ada.Numerics.Generic_Complex_Arrays is
   ...

with the set or a subset of the necessary entities "pre-instantiated" by the user? Is there a design "rule"?

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?

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?

No need to answer to all questions at once:-)

Thanks a lot.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-04-12 15:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-06 13:22 Generic library design Marius Amado-Alves
2018-04-07  2:32 ` Randy Brukardt
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

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