From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 X-Received: by 2002:a05:622a:205:: with SMTP id b5mr451207qtx.186.1619716668038; Thu, 29 Apr 2021 10:17:48 -0700 (PDT) X-Received: by 2002:a5b:448:: with SMTP id s8mr728753ybp.363.1619716667839; Thu, 29 Apr 2021 10:17:47 -0700 (PDT) Path: eternal-september.org!reader02.eternal-september.org!news.uzoreto.com!tr2.eu1.usenetexpress.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.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, 29 Apr 2021 10:17:47 -0700 (PDT) In-Reply-To: <56dc220e-1341-4a9f-98cc-132c8afdc2afn@googlegroups.com> Injection-Info: google-groups.googlegroups.com; posting-host=35.245.252.196; posting-account=XfA3zgkAAABoz6fRf3Tehtnqqr7Ycml- NNTP-Posting-Host: 35.245.252.196 References: <78fd99c3-538d-4981-af11-c1885df36575n@googlegroups.com> <7e2ece3d-893c-43fb-bf81-6002dbd0bc3dn@googlegroups.com> <56dc220e-1341-4a9f-98cc-132c8afdc2afn@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <5990d990-d8fc-489c-bb5d-7f047e14e06an@googlegroups.com> Subject: Re: [Ada95] Private non-generic children of generics not allowed From: Vincent Marciante Injection-Date: Thu, 29 Apr 2021 17:17:48 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:61930 List-Id: On Thursday, April 29, 2021 at 7:02:02 AM UTC-4, ehh.p...@gmail.com wrote: > On Thursday, April 29, 2021 at 12:20:07 PM UTC+2, Vincent Marciante wrote: > > > > (My specific need is in trying to keep down code duplication in a few different implementations > > of a generic package: separate body parts/files for each different implementation appear in different > > subdirectories and the build system picks the correct ones depending on the variant being built. > So what you want is a separate package/procedure/function: > > generic > package Generic_Foo is > procedure Bar; > end Generic_Foo; > > -- > > package body Generic_Foo is > Name : String := "generic Foo"; > > package Baz is > procedure Qux; > end Baz; > > package body Baz is separate; -magic! > > procedure Bar is > begin > Baz.Qux; > end Bar; > end Generic_Foo; > > -- > > with Ada.Text_IO; > separate(Generic_Foo) > package body Baz is > procedure Qux is > begin > Ada.Text_IO.Put_Line("Separate body of " & Name); > end Qux; > end Baz; > > > (Sorry in advance for google messing up indentation/formatting) That is pretty much what I have to do except that in my situation your procedure Bar would also be separate - and that makes the big difference: If private non-generic units were allowed (and visible only from the body of the parent generic) then the spec of your Baz package would not have to be declared in the body of Generic_Foo; it would be with'd only by the body of Bar (and any other separate that require it - without any additional declaration order requirements in the body of Generic_Foo. The situation would be worse if procedure Quz needed to have a parameter whose type was not from a package that was already visible to Genereic_Foo, forcing that package to be with'd in the body of Generic_Foo. _And_ if the required package would then cause a chain of dependencies to occur that are not even satisfiable in the variant environments that do not really require it then that package wouold also have to be dummied with null or exception-propagating subprograms. All of that could be avoided in a simple way if use of a private child unit as I have describe was made legal.