From: ark@ritcv.UUCP (Alan Kaminsky)
Subject: Re: What's wrong with this picture?
Date: 24 Oct 88 13:58:47 GMT [thread overview]
Message-ID: <961@ritcv.UUCP> (raw)
In-Reply-To: 8810211257.AA07315@savax.Sanders.COM
> What's wrong with this picture. The below package Data does not compile.
> It looks fine to me, but there must be something I'm missing. Does
> anyone see what I've overlooked. The with'd source, Data package, error
> listing and generic are all listed below.
> . . .
> --:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
> --Data.Ada
> --:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
> with Single_List_Utility;
> with Dynamic_String_Definition;
> use Dynamic_String_Definition;
>
> package Data is new Single_List_Utility(Element_Type =>
> Dynamic_String(Maximum_Length => 132) );
Summarizing the original posting: We are trying to instantiate a generic
package, Single_List_Utility, which has a single generic formal parameter,
Element_Type, that was declared to be a private type. In the instantiation,
we are trying to match this generic formal parameter with an actual type,
Dynamic_String, that has a discriminant, Maximum_Length. We are trying to
supply a value for the discriminant as we instantiate the generic package.
The goal is to instantiate a version of Single_List_Utility that works on
Dynamic_Strings of length 132. The compiler does not like this generic
instantiation.
The problem is simply one of Ada syntax. A generic_actual_parameter must
be a type_mark [ALRM 12.3] if the actual parameter is a data type. A
type_mark must be a type_name or subtype_name [ALRM 3.3.2]. Thus, the
generic actual parameter must be simply a name, not a name followed by a
discriminant.
Here is how to get what we want:
with Single_List_Utility;
with Dynamic_String_Definition;
use Dynamic_String_Definition;
subtype String_132 is Dynamic_String (Maximum_Length => 132);
package Data is new Single_List_Utility
(Element_Type => String_132);
--
Alan Kaminsky P. O. Box 9887
School of Computer Science Rochester, NY 14623
Rochester Institute of Technology 716-475-5255
ark@cs.rit.edu
next prev parent reply other threads:[~1988-10-24 13:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1988-10-21 12:57 What's wrong with this picture? Greg
1988-10-24 13:58 ` Alan Kaminsky [this message]
-- strict thread matches above, loose matches on Subject: below --
1991-08-29 11:33 SAHARBAUGH
1991-08-30 17:07 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!news.cs.indiana.e
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox