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=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!yunexus!geac!syntron!jtsv16!uunet!lll-winken!lll-tis!ames!mailrus!cornell!rochester!ritcv!ark From: ark@ritcv.UUCP (Alan Kaminsky) Newsgroups: comp.lang.ada Subject: Re: What's wrong with this picture? Message-ID: <961@ritcv.UUCP> Date: 24 Oct 88 13:58:47 GMT Article-I.D.: ritcv.961 References: <8810211257.AA07315@savax.Sanders.COM> Organization: Rochester Institute of Technology, Rochester, NY List-Id: > 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