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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8eff44ec1bcf8433 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-16 12:09:31 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeed.berkeley.edu!ucberkeley!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Container reqs Date: 16 Oct 2001 15:04:26 -0400 Organization: NASA Goddard Space Flight Center Message-ID: References: <9qctpn$lil$1@news.huji.ac.il> <3BCC1BEE.99169F8B@free.fr> <9qhcj0$anv$1@news.huji.ac.il> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1003259176 4249 128.183.220.71 (16 Oct 2001 19:06:16 GMT) X-Complaints-To: dscoggin@cne-odin.gsfc.nasa.gov NNTP-Posting-Date: 16 Oct 2001 19:06:16 GMT User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 Xref: archiver1.google.com comp.lang.ada:14732 Date: 2001-10-16T19:06:16+00:00 List-Id: "Ehud Lamm" writes: > > > > * the container types should be limited (one can always provides > > a clone function if needed). > > Right. > > > > > * the contained types should not be limited (one can always provides > > a standard wrapper for limited types) > > > > I also like this design. But others seem to disagree (maps of maps of maps > of ...), and I understand their pov. We should try to find the best > solution/compromise on this important issue. It is possible to write generic packages than can accept item types that are either limited or non-limited. See http://users.erols.com/leakstan/Stephe/Ada/Sal_Packages/index.htm, package sal-gen-lists-double.ads for example. Here's the critical part: generic type Item_Type (<>) is limited private; type Item_Node_Type is private; with function To_Item_Node (Item : in Item_Type) return Item_Node_Type; with procedure Free_Item (Item : in out Item_Node_Type); -- If Item_Type is definite non-limited, Item_Node_Type should just be -- Item_Type. Then To_Item_Node should just return Item, and Free_Item -- should be null (and both should be inlined). See -- SAL.Aux.Definite_Private_Items. -- -- If Item_Type is indefinite, Item_Node_Type should be 'access -- Item_Type'. Then To_Item_Node should allocate Item and return a -- pointer to it, and Free_Item should be Unchecked_Deallocation. See -- SAL.Aux.Indefinite_Private_Items. -- -- To create a list of limited objects (say of type Limited_Type), -- Item_Type can be a non-limited type holding the parameters needed to -- create an object (non-limited to allow the user to create aggregates -- of creation parameters), and Item_Node_Type can be 'access -- Limited_Type'. Then To_Item_Node must allocate an object of type -- Limited_Type and initialize it using the parameters in Item_Type. See -- SAL.Aux.Indefinite_Limited_Items. -- -- Other usages may be possible. -- -- Stephe