Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Generic library design

126 views
Skip to first unread message

Marius Amado-Alves

unread,
Apr 6, 2018, 9:22:37 AM4/6/18
to
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.

Randy Brukardt

unread,
Apr 6, 2018, 10:32:30 PM4/6/18
to

"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.


Message has been deleted

Marius Amado-Alves

unread,
Apr 12, 2018, 6:23:28 AM4/12/18
to
Thanks, very informative and useful.

(I create patentable ideas as I breathe...)

Dan'l Miller

unread,
Apr 12, 2018, 11:32:07 AM4/12/18
to
On Friday, April 6, 2018 at 9:32:30 PM UTC-5, Randy Brukardt wrote:
> Note that argubly sharing based on generic parameters is (was?) patented and
> not usable by implementers without legal issues.

Would you know any clues on how to track that patent down? Assignee corporation? Inventors? Patent number? Btw, if it isn't RR Software and that patent isn't decades old, then either they patented a significantly different technique or Janus Ada's long-standing capability on this topic clearly invalidates their patent as their mere mimicking of long-standing & widely-disseminated existing practice within Janus Ada, assuming that decades old versions of publicly-for-sale Janus Ada are still extant and still execute.

Perhaps on a different note, I see that Oracle has been quite active in recent years regarding the application for patents in the parameterized-type conceptual-space regarding compilers. Apparently a strategy over there is to try to assure that only Java has all the cool toys in their toybox, leaving Ada, C++, OCaml, C#, and so forth with older-era technology for 20 years. One inventor's name keeps recurring on nearly every one of those patents.

Dan'l Miller

unread,
Apr 12, 2018, 11:41:21 AM4/12/18
to
On Thursday, April 12, 2018 at 5:23:28 AM UTC-5, Marius Amado-Alves wrote:
> Thanks, very informative and useful.
>
> (I create patentable ideas as I breathe...)

Btw, (wishful) ideas themselves are not patentable. Only the apparatus(es) and method(s) that bring those ideas into fruition (as reified reality) are patentable. (And thus many patents are able to be bypassed via a different apparatus and/or different method to accomplish the idea's outcome/wish—and thus why new patents on new variants on paperclips are often valid fresh inventions: the wishful idea of a paperclip that doesn't fall off isn't what is being patented; the apparatus or method for •how• to increase friction of paperclip to paper is what is being patented.)
0 new messages