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.6 required=3.0 tests=BAYES_00,PDS_FROM_2_EMAILS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Received: by 2002:a05:622a:164b:b0:344:513b:ffc0 with SMTP id y11-20020a05622a164b00b00344513bffc0mr24585820qtj.350.1662047422162; Thu, 01 Sep 2022 08:50:22 -0700 (PDT) X-Received: by 2002:a81:6cd7:0:b0:33d:cd0f:123a with SMTP id h206-20020a816cd7000000b0033dcd0f123amr23376440ywc.422.1662047421900; Thu, 01 Sep 2022 08:50:21 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!news.misty.com!border-2.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: Thu, 1 Sep 2022 08:50:21 -0700 (PDT) In-Reply-To: <401d6f59-2c28-4dd5-9fa6-fccf33b6d645n@googlegroups.com> Injection-Info: google-groups.googlegroups.com; posting-host=91.250.172.85; posting-account=SuyozQoAAADXnDELfODTBs7QDv_fdf87 NNTP-Posting-Host: 91.250.172.85 References: <67b32db0-c4db-466c-ac13-e597e008c762n@googlegroups.com> <401d6f59-2c28-4dd5-9fa6-fccf33b6d645n@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <8716804b-8041-4aae-ba48-276cecce7881n@googlegroups.com> Subject: Re: Calling inherited primitive operations in Ada From: "amo...@unizar.es" Injection-Date: Thu, 01 Sep 2022 15:50:22 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:64257 List-Id: On Thursday, September 1, 2022 at 4:11:54 PM UTC+2, briot.e...@gmail.com wr= ote: > I have seen quite a number of cases of needing the subtype like Dmitry wa= s showing. In a small number of cases, those were actual bugs in GNAT, but = most of the time the compiler was correct.=20 > Mostly, you start to see the issue when you have generic packages that ha= ve formal generic packages.=20 This matches exactly my experience. I don't have enough grasp of the detail= s to come up with a realistic short example, but I did hit this issue prett= y often in two libs were I used signature packages quite extensively: https://github.com/mosteo/rxada https://github.com/mosteo/iterators Initially I was always under the impression I was hitting GNAT bugs but the= n it turned out there were rules about it. A couple example places (you can= see the renamings at the top. I was adding them "on demand" so to say): https://github.com/mosteo/iterators/blob/master/src/iterators-traits-contai= ners.ads https://github.com/mosteo/rxada/blob/master/src/priv/rx-impl-transformers.a= ds =20 Thanks Emmanuel for the examples and digging out Tucker explanation. -Alex. > There are more interesting examples, somehow this one doesn't seem that b= ad. So here is another one:=20 >=20 > generic=20 > type T is private;=20 > package Gen is=20 > end Gen;=20 >=20 > with Gen;=20 > generic=20 > type T is private;=20 > with package Must_Match is new Gen (T);=20 > with package Need_Not_Match is new Gen (<>);=20 > package Gen2 is=20 > V1 : Must_Match.T; -- "T" is not a visible entity of "Must_Match"=20 > V2 : Need_Not_Match.T; -- instance of same package, but this time T is vi= sible=20 > end Gen2;=20 >=20 > with Gen, Gen2;=20 > procedure P2 is=20 > package G is new Gen (Integer);=20 > package G2 is new Gen2 (Integer, G, G);=20 > begin=20 > null;=20 > end P2;=20 >=20 >=20 >=20 >=20 > I dug out the explanation that Tucker Taft once sent to the Ada-Comment m= ailing list (2019-11-14):=20 >=20 > <<<=20 > 10/2=20 > {AI95-00317-01} The visible part of a formal package includes the first l= ist of basic_declarative_items of the package_specification. In addition, f= or each actual parameter that is not required to match, a copy of the decla= ration of the corresponding formal parameter of the template is included in= the visible part of the formal package. If the copied declaration is for a= formal type, copies of the implicit declarations of the primitive subprogr= ams of the formal type are also included in the visible part of the formal = package.=20 > 10.a/2=20 > Ramification: {AI95-00317-01} If the formal_package_actual_part is (<>), = then the declarations that occur immediately within the generic_formal_part= of the template for the formal package are visible outside the formal pack= age, and can be denoted by expanded names outside the formal package.If onl= y some of the actual parameters are given by <>, then the declaration corre= sponding to those parameters (but not the others) are made visible.=20 > 10.b/3=20 > Reason: {AI05-0005-1} We always want either the actuals or the formals of= an instance to be nameable from outside, but never both. If both were name= able, one would get some funny anomalies since they denote the same entity,= but, in the case of types at least, they might have different and inconsis= tent sets of primitive operators due to predefined operator =E2=80=9Creemer= gence.=E2=80=9D Formal derived types exacerbate the difference. We want the= implicit declarations of the generic_formal_part as well as the explicit d= eclarations, so we get operations on the formal types.=20 > >>>