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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable 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!usenet-fr.net!enst.fr!melchior!cuivre.fr.eu.org!melchior.frmug.org!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: array of generic packages? Date: 22 Sep 2004 19:30:07 -0400 Organization: Cuivre, Argent, Or Message-ID: References: <4151be92@dnews.tpgi.com.au> NNTP-Posting-Host: lovelace.ada-france.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: melchior.cuivre.fr.eu.org 1095895816 27205 212.85.156.195 (22 Sep 2004 23:30:16 GMT) X-Complaints-To: usenet@melchior.cuivre.fr.eu.org NNTP-Posting-Date: Wed, 22 Sep 2004 23:30:16 +0000 (UTC) To: comp.lang.ada@ada-france.org Return-Path: In-Reply-To: <4151be92@dnews.tpgi.com.au> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Gateway to the comp.lang.ada Usenet newsgroup" List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: g2news1.google.com comp.lang.ada:3974 Date: 2004-09-22T19:30:07-04:00 "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); This is not directly possible. But perhaps you are looking for tagged types: type Shape_Type is tagged abstract limited private; type Shape_Access_Type is access all Shape_Type; procedure Draw (Item : in Shape_Type); type Circle_Type is new Shape_Type with private; procedure Draw (Item : in Circle_Type); function New_Circle (Radius : in Float) return Shape_Access_Type; type Triangle_Type is new Shape_Type with private; procedure Draw (Item : in Triangle_Type); function New_Triangle (A, B, C : in Float) return Shape_Access_Type; Then you can do things like: type Shape_Array_Type is array (...) of Shape_Access_Type; My_Shapes : Shape_Array_Type := (New_Circle (2.0), New_Triangle (3.0, 4.0, 5.0)); for I in My_Shapes'range loop Draw (My_Shapes (I).all); end loop; If that's not what you want, perhaps you could say more about what you do want, and we could talk about how to do it "the Ada way". -- -- Stephe