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,7009541db2ced1ad X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!r10g2000prf.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Construction initialization problem Date: Thu, 4 Dec 2008 09:35:23 -0800 (PST) Organization: http://groups.google.com Message-ID: <80b2a531-3c9e-48c0-a809-2d6b3e1c20da@r10g2000prf.googlegroups.com> References: NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1228412124 16112 127.0.0.1 (4 Dec 2008 17:35:24 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 4 Dec 2008 17:35:24 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: r10g2000prf.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:3843 Date: 2008-12-04T09:35:23-08:00 List-Id: On Dec 4, 8:08 am, "Dmitry A. Kazakov" wrote: > Consider this: > > type A is tagged limited null record; > type B (X : not null access A'Class) is tagged limited null record; > > Now we want to specialize B so that its instances would already contain A: > > type C is new B with record > Y : aliased A; > end record; > > Now there seems no way to either create an object of C so that C.X would > point to C.Y or else to derive from C a new type without discriminant: > > type D is new C (X => C.Y'Access) with null record; -- Illegal > type D is new C (X => D.Y'Access) with null record; -- Illegal > On a related note, you can't do this either: type Rec1 is tagged null record; type Rec2 (D : access Rec1) is tagged limited record ... end record; type Rec3 is record F1 : aliased Rec1; F2 : Rec2 (Rec3.F1'access); end record; The rule preventing this is in 3.8, which says that the only component of "current instance" that you can use is a noninherited discriminant---and F1 is not a discriminant. But offhand, I don't think this restriction is necessary when the component is used as the prefix of 'Access. There shouldn't be any accessibility level issues, I think. Some care might be needed to get the language rules right in case the component is in a variant part, but other than that I can't think of any difficulties either in adding a rule to allow this or in implementation. Of course that doesn't mean there aren't any difficulties, just that I can't think of them. Simply adding that rule wouldn't quite solve Dmitry's problem, since in this case: type D is new C (X => D.Y'Access) with null record; -- Illegal he's trying to use a current instance in a discriminant, which a different clause in 3.8(12) makes illegal. Also, the issue of writing an allocator for type C whose discriminant refers to C would seem to require new syntax---maybe if we borrow the "extended return" idea? New_Obj := new ZZZ : C (X => ZZZ.Y'Access); -- Adam