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 2002:a24:8343:: with SMTP id d64-v6mr3852435ite.32.1522545170716; Sat, 31 Mar 2018 18:12:50 -0700 (PDT) X-Received: by 2002:a9d:2281:: with SMTP id y1-v6mr229538ota.14.1522545170615; Sat, 31 Mar 2018 18:12:50 -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!nntp.giganews.com!k65-v6no763846ita.0!news-out.google.com!d3-v6ni1206itf.0!nntp.google.com!u184-v6no2546324ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 31 Mar 2018 18:12:50 -0700 (PDT) In-Reply-To: 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: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: limited agregate and limited components default initialization From: Jere Injection-Date: Sun, 01 Apr 2018 01:12:50 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:51265 Date: 2018-03-31T18:12:50-07:00 List-Id: On Saturday, March 31, 2018 at 8:52:39 PM UTC-4, Jere wrote: > On Saturday, March 31, 2018 at 7:36:59 PM UTC-4, Jean-Claude Rostaing wrote: > > Why does a component declaration like that: > > type Item_Accessor (Item: not null access Item_type) is limited record > > Ref: Item_access := SET(Item_Record'(Item => ITEM.all, others => <>)); > > end record; > > unconstrained subtype in component declaration > > ? ITEM is limited but IS constrained by the default initialisation > > It forced me to add the function DEFAULT_INITIALIZATION as a parameter, which I would prefer to not to. But since the result is the same, I'll drop it. > > Item (and the article it is in) is never meant to be left uninitialized. > > > > Also, how to get rid of the problem with > > function Set (Value: in Item_type) return Smart_Pointers is > > (Smart_Pointers'(Controlled with Node => new Accessor_type'(Data => new Item_type'(Value), Count => 1))); > > which gives :Initialization not allowed for limited types. > > So an aggregate like this is not counted as a "limited agregate" ?? > > I may be misunderstanding you, but if Item is a limited type with a default > discriminant, it is "unconstrained" since the ada compiler cannot know > at compile time what the actual size will be. > > See: > https://gcc.gnu.org/onlinedocs/gnat_rm/The-Size-of-Discriminated-Records-with-Default-Discriminants.html Actually, the limited might make it ok, but I seem to remember it still being considered unconstrained from a language point of view. Perhaps a language lawyer type can make a better comment.