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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,eeb3ea7993143012 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.195.131 with SMTP id ie3mr8328030pbc.8.1337225823182; Wed, 16 May 2012 20:37:03 -0700 (PDT) Path: pr3ni7622pbb.0!nntp.google.com!news2.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Declaring private packages to instantiate generics? Date: Wed, 16 May 2012 20:37:02 -0700 (PDT) Organization: http://groups.google.com Message-ID: <7294223.88.1337225822800.JavaMail.geo-discussion-forums@vbli11> References: <25586653.906.1337178987063.JavaMail.geo-discussion-forums@pbcvy1> NNTP-Posting-Host: 68.4.246.214 Mime-Version: 1.0 X-Trace: posting.google.com 1337225823 4796 127.0.0.1 (17 May 2012 03:37:03 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 17 May 2012 03:37:03 +0000 (UTC) In-Reply-To: <25586653.906.1337178987063.JavaMail.geo-discussion-forums@pbcvy1> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=68.4.246.214; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-05-16T20:37:02-07:00 List-Id: On Wednesday, May 16, 2012 7:36:27 AM UTC-7, Adam Beneschan wrote: > > package FOO is > > procedure P; > > end FOO; > >=20 > > package body FOO is > > package BAR is new SOME_GENERIC_PACKAGE; > > procedure P is new BAR.P; > > end FOO; > > --->%--- > >=20 > > Can I somehow provide the body of P without writing a procedure which j= ust=20 > > forwards to an instantiation of BAR.P, IOW without having to write: > >=20 > > ---%<--- > > package body FOO is > > package BAR is new SOME_GENERIC_PACKAGE; > > procedure BAR_P is new BAR.P; > > procedure P is begin BAR_P; end; > > end FOO; > > --->%--- > >=20 > > Regards, > > Markus >=20 > You can change the last to >=20 > procedure P renames BAR_P; >=20 > But that's the best you can do. If you have an incomplete declaration (i= .e. the declaration of P in the *spec* of FOO), you can't complete it with = a generic instantiation---that's the rule. (I think he reason is that a ge= neric instantiation is equivalent to a declaration of the instance followed= by the body of the instance, and doing that here would mean you're declari= ng P twice, which isn't allowed. It can be argued that the language rules = should be relaxed in this case, since it's tripped up more than one person,= and offhand I don't see any complications that would arise if it were allo= wed.) I just got reminded by Tucker Taft that there's a problem if P has paramete= rs. The parameters aren't listed in a generic_instantiation: package FOO is procedure P (Param : in Integer; Param2 : out Integer); end FOO; =20 package body FOO is package BAR is new SOME_GENERIC_PACKAGE; procedure P is new BAR.P; end FOO; This makes it less clear to the eye that the second P completes the first o= ne. (This would especially be a problem if there is more than one P with d= ifferent parameter profiles in the specification.) This makes it clearer: package FOO is procedure P (Param : in Integer; Param2 : out Integer); end FOO; =20 package body FOO is package BAR is new SOME_GENERIC_PACKAGE; procedure New_P is new BAR.P; procedure P (Param : in Integer; Param2 : out Integer) renames New_P; end FOO; So there's a good reason why the rules are the way they are. -- Adam