From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,FREEMAIL_FROM, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Received: by 2002:a05:620a:4007:b0:6be:91e8:c94e with SMTP id h7-20020a05620a400700b006be91e8c94emr23630612qko.375.1662361003971; Sun, 04 Sep 2022 23:56:43 -0700 (PDT) X-Received: by 2002:a81:6d8b:0:b0:345:1065:7515 with SMTP id i133-20020a816d8b000000b0034510657515mr7759773ywc.135.1662361003698; Sun, 04 Sep 2022 23:56:43 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!border-1.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 4 Sep 2022 23:56:43 -0700 (PDT) In-Reply-To: Injection-Info: google-groups.googlegroups.com; posting-host=2a01:e0a:810:89e0:fc7b:9a2c:126e:2e67; posting-account=6yLzewoAAABoisbSsCJH1SPMc9UrfXBH NNTP-Posting-Host: 2a01:e0a:810:89e0:fc7b:9a2c:126e:2e67 References: <67b32db0-c4db-466c-ac13-e597e008c762n@googlegroups.com> <401d6f59-2c28-4dd5-9fa6-fccf33b6d645n@googlegroups.com> <12cc33b1-2c39-4057-8a03-623064b06e8en@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <458444ed-e384-4663-896c-bb38dae3c5cbn@googlegroups.com> Subject: Re: Calling inherited primitive operations in Ada From: Emmanuel Briot Injection-Date: Mon, 05 Sep 2022 06:56:43 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader01.eternal-september.org comp.lang.ada:64286 List-Id: Jeff Carter: > Where is that? All I saw in my quick look were Maps, Maps.Generics, and Maps.Impl. Simon Wright: > And this was one reason that I didn't put up any arguments at Ada Europe > 2002 for the Ada 95 Booch Components to form a basis for Ada.Containers > - you'd need 3 instantiations, one after the other. I definitely see the same issue. The way my library is trying to workaround that is as follows: Those instantiations are only needed for people who want/need to control every aspects of their containers, for instance how elements are stored, how/when memory is allocated, what is the growth strategy for vectors, and so on. Most users should not have to care about that in practice. So we use code generation at compile time to generate high-level packages similar to the Ada containers, with a limited set of formal parameters (in src/generated, to be more specific). We can generate bounded/unbounded versions, definite/indefinite versions, and any combination of those. One of the intentions of the library, initially, had been the implementation of the Ada containers and SPARK containers in GNAT, as a way to share as much code as possible between the two. Randy Brukardt: > Assuming otherwise is certainly premature optimization. I am quoting a bit out of context, though I believe it is close enough. Designers of containers must care about performance from the get-go. Otherwise, people might just as well use a list for everything and just traverse the list all the time. We all know this would be way too inefficient, of course, which is why there are various sorts of containers. Anyone who has actually written performance-sensitive code knows that memory allocations is definitely something to watch out for, and the library design should definitely take that into account. Jeff Carter: > The only indefinite data structure that is needed seems to be holders Although it is certainly true that using holders works, it is not applicable when designing a containers library that intends to be mostly compatible with Ada containers. The latter have chosen, long ago and before Holder was a thing, to have definite and indefinite versions. The main benefit to this approach is that users still retrieve directly the type they are interested in (e.g. String) rather than a holder-to-string. I must admit I have very limited experience with Holders, which I have never used in production code (nor, apparently, have my colleagues and ex-colleagues). Randy Brukardt: > Ada *DOES* support default values for formal parameters of generics Hey, I just discovered that, thanks Randy ! For people who also did not know that: generic type Item_Count is range <> or use Natural; package Gen is It is supported by GNAT's newer versions (I don't know when it was implemented though)