comp.lang.ada
 help / color / mirror / Atom feed
From: Vincent Marciante <vincent.marciante@l3harris.com>
Subject: Re: [Ada95] Private non-generic children of generics not allowed
Date: Thu, 29 Apr 2021 10:17:47 -0700 (PDT)	[thread overview]
Message-ID: <5990d990-d8fc-489c-bb5d-7f047e14e06an@googlegroups.com> (raw)
In-Reply-To: <56dc220e-1341-4a9f-98cc-132c8afdc2afn@googlegroups.com>

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.

  reply	other threads:[~2021-04-29 17:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-26 15:43 [Ada95] Private non-generic children of generics not allowed Vincent Marciante
2021-04-26 16:41 ` AdaMagica
2021-04-26 16:53   ` Vincent Marciante
2021-04-26 17:16     ` AdaMagica
2021-04-28 12:09       ` Vincent Marciante
2021-04-28 17:57         ` AdaMagica
2021-04-29  8:57 ` AdaMagica
2021-04-29 10:20   ` Vincent Marciante
2021-04-29 11:02     ` Egil H H
2021-04-29 17:17       ` Vincent Marciante [this message]
2021-04-29 17:43         ` AdaMagica
2021-04-29 19:29           ` Vincent Marciante
2021-04-30 12:56             ` AdaMagica
2022-04-28  0:07               ` Thomas
2022-05-19 19:59                 ` Indra Anita
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox