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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.107.138.223 with SMTP id c92mr2300194ioj.85.1522551294635; Sat, 31 Mar 2018 19:54:54 -0700 (PDT) X-Received: by 2002:a9d:4045:: with SMTP id o5-v6mr241732oti.6.1522551294549; Sat, 31 Mar 2018 19:54:54 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!paganini.bofh.team!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!k65-v6no829225ita.0!news-out.google.com!u64-v6ni3388itb.0!nntp.google.com!u184-v6no2614029ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 31 Mar 2018 19:54:54 -0700 (PDT) In-Reply-To: <27d34604-c37e-4731-886d-41cdc6addfec@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=173.71.218.250; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf NNTP-Posting-Host: 173.71.218.250 References: <6b8fb3ef-700f-4930-9a1e-5126d9482a26@googlegroups.com> <3d0554a2-95e8-4f8f-9fdf-1743d3f1dc18@googlegroups.com> <27d34604-c37e-4731-886d-41cdc6addfec@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <701dc084-b5ea-4990-9c06-a56fd738a4fa@googlegroups.com> Subject: Re: limited agregate and limited components default initialization From: Jere Injection-Date: Sun, 01 Apr 2018 02:54:54 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:51270 Date: 2018-03-31T19:54:54-07:00 List-Id: On Saturday, March 31, 2018 at 10:40:22 PM UTC-4, Jere wrote: > On Saturday, March 31, 2018 at 10:07:20 PM UTC-4, Jean-Claude Rostaing wrote: > > -- > > -- Item_type and ITEM_RECORD are NOT meant to be declared uninitialized, ever. > > -- So how do I tell this to GNAT so that Item: aliased ITEM_TYPE as a component is allowed ? > > -- Implementing List_type with common access types and "type Bla, type Blabla is access Bla, complete declaration" would have been easy, but the private type Smart_Pointers made a hell of it. > > > > with Pointers; > > > > generic > > type Item_Type(<>) is limited private; > > package Lists is > > type List_Type is limited private; > > type Item_Accessor (Item: not null access Item_type) is limited private with Implicit_Dereference => Item; > > function Get(Position: in List_Iterator) return Item_Accessor; > > private > > type ITEM_ACCESS; > > type Item_Record is limited > > record > > Item: aliased Item_type; > > Next : Item_Access; > > Pred : Item_Access; > > end record; > > package Record_Pointers is new Pointers (Item_type => Item_Record); > > type Item_Access is new Record_Pointers.Smart_Pointers; > > > > type Item_Accessor (Item: not null access Item_type) is limited record > > REF: ITEM_ACCESS := SET(ITEM_RECORD'(ITEM.all, others => <>)); > > end record; > > > > type List_Type is limited record > > First: Item_Access; > > Last : Item_Access; > > Count : Natural := 1; > > end record; > > end Lists; > > > > And what I was pointing your attention at was: > > lists.ads:39:49: initialization not allowed for limited types > > for: REF: ITEM_ACCESS := SET(ITEM_RECORD'(ITEM.all, others => <>)); > > Ok, your problems: > 1. For your Item_Record type, the parameter Item, cannot be of type > Item_Type as it is unconstrained. That is what gives you the first > error To clarify because I typed that horribly: Item_Type cannot be an unconstrained type if you wish to make it a component of a record. It needs a constraint. That's why you have to remove the (<>) in your generic formal for Item_Type.