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,52b823433320210c X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!proxad.net!newsfeed.stueberl.de!newsgate.cistron.nl!transit.news.xs4all.nl!195.241.76.212.MISMATCH!tiscali!transit1.news.tiscali.nl!dreader2.news.tiscali.nl!not-for-mail Newsgroups: comp.lang.ada Subject: Re: array of generic packages? References: <4151be92@dnews.tpgi.com.au> From: Ludovic Brenta Date: Wed, 22 Sep 2004 20:26:40 +0200 Message-ID: <87zn3idusf.fsf@insalien.org> User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) Cancel-Lock: sha1:MCV9Anxf1RUdjR+PsfzzYAinmQM= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: Tiscali bv NNTP-Posting-Date: 22 Sep 2004 20:29:24 CEST NNTP-Posting-Host: 83.134.238.131 X-Trace: 1095877764 dreader2.news.tiscali.nl 44093 83.134.238.131:35340 X-Complaints-To: abuse@tiscali.nl Xref: g2news1.google.com comp.lang.ada:3953 Date: 2004-09-22T20:29:24+02:00 List-Id: "a malkiel" writes: > hi im somewhat new to ada. i've been trying to nut this one but can't seem > to. Would anyone know if defining an "array of generic packages" is > possible? What im looking for is something of the nature: > > type shape_type is (circle, triangle); > package shapePointer(1) is new shape(circle); > package shapePointer(2) is new shape(triangle); > > thanks in advance. > ciao, andrew No, you cannot have an array of generic packages. You can only have arrays of objects; objects are constants and variables. You can create a generic package that declares a new type of arrays, like so: generic type Element_Type is private; package Generic_Arrays is type Array_Type is array (Positive range <>) of Element_Type; end Generic_Arrays; type Triangle is ... package Arrays_Of_Triangles is new Generic_Arrays (Element_Type => Triangle); My_Triangle : Triangle; My_Array : Arrays_Of_Triangles.Array_Type := (1 => My_Triangle); However, the generic package is not really all that useful if all you want is to declare new array types. You'd be better off doing just: type Array_Of_Triangles is array (Positive range <>) of Triangle; type Array_Of_Circles is array (Positive range <>) of Circle; which does not require a generic. -- Ludovic Brenta.