From: "Chad R. Meiners" <crmeiners@hotmail.com>
Subject: Re: Problem with instantiating generic procedure
Date: 1999/07/18
Date: 1999-07-18T00:00:00+00:00 [thread overview]
Message-ID: <932349592.866.100@news.remarQ.com> (raw)
In-Reply-To: 7ms4en$kl8$1@pegasus.csx.cam.ac.uk
Perhaps the follow solution is an acceptable alterative to renaming generic
instantiations:
Package Generics is
generic
Type Parameter is private;
procedure G(Item : Parameter);
end Generics;
Package body Generics is
Procedure G(Item : Parameter) is
begin
null;
end G;
end Generics;
with Generics;
Package Instantiations is
Procedure A is new Generics.G(Integer);
--Procedure A(Item : Integer);
end Instantiations;
The only problem with this solution is that Generics is not a private
package, but I don't think that would
be a problem in your case.
-Chad R. Meiners
Markus Kuhn <mgk25@cl.cam.ac.uk> wrote in message
news:7ms4en$kl8$1@pegasus.csx.cam.ac.uk...
> Florian Weimer <fw@s.netic.de>:
> |> ARM 6.1(20):
> |>
> |> | A subprogram_declaration or a generic_subprogram_declaration requires
> |> | a completion: a body, a renaming_declaration (see 8.5), or a pragma
> |> | Import (see B.1). A completion is not allowed for an
> |> | abstract_subprogram_declaration.
>
> Thanks! But the RM also says in section 12.3:
>
> A generic_instantiation declares an instance; it is equivalent to the
> instance declaration (a package_declaration or subprogram_declaration)
> immediately followed by the instance body, both at the place of the
> instantiation.
>
> So if 6.1 says that a subprogram_declaration requires a body and 12.3 says
that
> a generic instantiation does provide the equivalent of a body, then I
still
> do not understand where the RM says that my program is illegal. In
addition,
> I see absolutely no good reason, why the language should forbid this. It
just
> requires an ugly workaround via renaming, which forces me to pollute the
object
> namespace and makes the code less readable by introducing yet another
temporary
> name for something. In my case, I make over 30 instantiations (I am
writing a type-safe
> binding for the linux ioctl() system calls), so I also have to add now
over 30
> renames, which looks really ugly.
>
> I guess I'll submit it as a bug report to ACT and let them decide whether
it is
> just an unclear error message or a non-conformity to the RM. In any case,
if someone
> keeps an Ada 0X wish list, please put adding generic instantiations to
6.1(20) onto
> it.
>
> |> I guess this means that an instance of a generic subprogram isn't
allowed
> |> as a completion for a subprogram declaration. The obvious workaround
> |> is using a renaming declaration. Of course, the GNAT error message
> |> could be a bit more helpful.
>
> Markus
>
> --
> Markus G. Kuhn, Computer Laboratory, University of Cambridge, UK
> Email: mkuhn at acm.org, WWW: <http://www.cl.cam.ac.uk/~mgk25/>
next prev parent reply other threads:[~1999-07-18 0:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-07-17 0:00 Problem with instantiating generic procedure Markus Kuhn
1999-07-17 0:00 ` Vladimir Olensky
1999-07-17 0:00 ` Florian Weimer
1999-07-18 0:00 ` Markus Kuhn
1999-07-18 0:00 ` Florian Weimer
1999-07-19 0:00 ` Robert Dewar
1999-07-19 0:00 ` Florian Weimer
1999-07-18 0:00 ` Chad R. Meiners [this message]
1999-07-18 0:00 ` David C. Hoos, Sr.
1999-07-19 0:00 ` Tucker Taft
1999-07-19 0:00 ` Markus Kuhn
1999-07-23 0:00 ` Tucker Taft
1999-07-19 0:00 ` Robert A Duff
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox