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,ca20ac98709f9b4a X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!g17g2000prg.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Array of Strings Date: Tue, 23 Sep 2008 07:41:06 -0700 (PDT) Organization: http://groups.google.com Message-ID: <8f9b845c-468c-40b1-a906-c67bb573b645@g17g2000prg.googlegroups.com> References: <0e021c61-535a-4935-95ad-2a241fa7302f@e53g2000hsa.googlegroups.com> <03c0a846-728a-4944-9529-9b941f7361e9@y21g2000hsf.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1222180866 29094 127.0.0.1 (23 Sep 2008 14:41:06 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 23 Sep 2008 14:41:06 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: g17g2000prg.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:2075 Date: 2008-09-23T07:41:06-07:00 List-Id: On Sep 23, 7:30 am, mockturtle wrote: > On Sep 23, 4:07 pm, jedivaughn wrote: > > > > > If I wanted to make a package that made the array generic how would I > > go about doing this. this is what I have which isn't working. > > > generic > > > type Element_Type is (<>); > > type range1 is (<>); > > > package list is > > type letters is private; > > > private > > type letters is array (range1) of Element_Type; > > > end list; > > > and then in the main program I want > > > subtype range2 is integer range 1..25; > > subtype str_length is string (1..25); > > > package List1 is new List(Element_Type => str_length, range1 => > > range2 ); > > > when I try to compile the main program I get "expect discrete type in > > instantiation of "Element_Type"" > > > what am I doing wrong? > > According to RM 12.5.2 "type Element_Type is (<>);" means that > Element_Type > is a discrete type. I guess that you want something like > "type Element_Type is private;" (I did not check) Yes, that's right. When you declare a generic formal type (a "type" declaration between the keyword "generic" and the beginning of the package or procedure declaration), there are several ways to declare the type, and the different ways control what sorts of types you can use to instantiate the generic. Here's an incomplete rundown: type T is private; -- T can be any nonlimited type except an -- unconstrained type type T(<>) is private; -- T can be any nonlimited type type T is (<>); -- T must be discrete, i.e. integer or -- enumeration type T is range <>; -- T must be a signed (non-modular) integer type type T is mod <>; -- T must be a modular type type T is digits <>; -- T must be a floating-point type type T is delta <>; -- T must be a fixed-point type, not decimal fixed type T is delta <> digits <>; -- T must be a decimal fixed-point type You can also declare formal array types, access types, and derived types. Also, the "private" generic formal declarations can have "tagged" and/or "limited" keywords applied. See the manual (12.5) for more information. -- Adam