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!p25g2000hsf.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Array of Strings Date: Tue, 23 Sep 2008 07:47:23 -0700 (PDT) Organization: http://groups.google.com Message-ID: <28f46a26-60d3-436d-96bb-11404fa66b4d@p25g2000hsf.googlegroups.com> References: <0e021c61-535a-4935-95ad-2a241fa7302f@e53g2000hsa.googlegroups.com> <03c0a846-728a-4944-9529-9b941f7361e9@y21g2000hsf.googlegroups.com> NNTP-Posting-Host: 153.98.68.197 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1222181244 30414 127.0.0.1 (23 Sep 2008 14:47:24 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 23 Sep 2008 14:47:24 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: p25g2000hsf.googlegroups.com; posting-host=153.98.68.197; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.3) Gecko/20040924,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:2076 Date: 2008-09-23T07:47:23-07:00 List-Id: 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) That's correct. To the OP: out of curiosity, why don't you use Ada.Containers.Vectors? Even if you have good reason not to use this package, you will benefit from reading its spec as a source of inspiration (aka "best practices"). Also see http://en.wikibooks.org/wiki/Ada_Programming/Generics -- Ludovic Brenta.