comp.lang.ada
 help / color / mirror / Atom feed
From: Marius Amado-Alves <amado.alves@gmail.com>
Subject: Generic library design
Date: Fri, 6 Apr 2018 06:22:35 -0700 (PDT)
Date: 2018-04-06T06:22:35-07:00	[thread overview]
Message-ID: <1d9faa0f-d3d7-4eb4-aa88-b50ed1e9aac3@googlegroups.com> (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.


             reply	other threads:[~2018-04-06 13:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-06 13:22 Marius Amado-Alves [this message]
2018-04-07  2:32 ` Generic library design 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
replies disabled

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