From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!gandalf.srv.welterde.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Generic library design Date: Fri, 6 Apr 2018 21:32:28 -0500 Organization: JSA Research & Innovation Message-ID: References: <1d9faa0f-d3d7-4eb4-aa88-b50ed1e9aac3@googlegroups.com> Injection-Date: Sat, 7 Apr 2018 02:32:29 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="785"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:51371 Date: 2018-04-06T21:32:28-05:00 List-Id: "Marius Amado-Alves" 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.