From: Adam Beneschan <adam@irvine.com>
Subject: Re: Declaring private packages to instantiate generics?
Date: Wed, 16 May 2012 07:36:27 -0700 (PDT)
Date: 2012-05-16T07:36:27-07:00 [thread overview]
Message-ID: <25586653.906.1337178987063.JavaMail.geo-discussion-forums@pbcvy1> (raw)
In-Reply-To: <jp0d51$q7e$1@speranza.aioe.org>
On Wednesday, May 16, 2012 7:21:24 AM UTC-7, Markus Schöpflin wrote:
> I just found myself wanting to write the following code, which Gnat doesn't like:
>
> ---%<---
> package FOO is
> procedure P;
> end FOO;
>
> package body FOO is
> package BAR is new SOME_GENERIC_PACKAGE;
> procedure P is new BAR.P;
> end FOO;
> --->%---
>
> Can I somehow provide the body of P without writing a procedure which just
> forwards to an instantiation of BAR.P, IOW without having to write:
>
> ---%<---
> 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;
> --->%---
>
> Regards,
> Markus
You can change the last to
procedure P renames BAR_P;
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 generic instantiation is equivalent to a declaration of the instance followed by the body of the instance, and doing that here would mean you're declaring 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 allowed.)
-- Adam
next prev parent reply other threads:[~2012-05-16 14:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-16 14:21 Declaring private packages to instantiate generics? Markus Schöpflin
2012-05-16 14:36 ` Adam Beneschan [this message]
2012-05-16 14:45 ` Markus Schöpflin
2012-05-17 1:24 ` Shark8
2012-05-17 3:37 ` Adam Beneschan
2012-05-21 8:06 ` Markus Schöpflin
2012-05-21 15:51 ` Simon Wright
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox