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,5c89acd494ea9116 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!w3g2000hsg.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Self pointer in limited record Date: Mon, 10 Sep 2007 10:13:23 -0700 Organization: http://groups.google.com Message-ID: <1189444403.391883.298370@w3g2000hsg.googlegroups.com> References: <1183577468.034566.57830@n60g2000hse.googlegroups.com> <1188578849.187422.280620@50g2000hsm.googlegroups.com> <9fy1xoukz1e3$.h574sqmiauri$.dlg@40tude.net> <1189441670.293887.176810@g4g2000hsf.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1189444403 12859 127.0.0.1 (10 Sep 2007 17:13:23 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 10 Sep 2007 17:13:23 +0000 (UTC) In-Reply-To: <1189441670.293887.176810@g4g2000hsf.googlegroups.com> 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) Complaints-To: groups-abuse@google.com Injection-Info: w3g2000hsg.googlegroups.com; posting-host=66.126.103.122; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 Xref: g2news2.google.com comp.lang.ada:1865 Date: 2007-09-10T10:13:23-07:00 List-Id: On Sep 10, 9:27 am, amado.al...@gmail.com wrote: > > > > ... I wish this were > > > > possible myself. Or more simply: > > > > > type T is -- limited or not > > > > Self : access T := T'Unchecked_Access; > > > > ... > > > > end; (Marius) > > > > T cannot be non-limited, because otherwise passing it by copy would make > > > rubbish out of Self. In any case it would make little sense if not access > > > T'Class. (Kasakov) > > > Sure it can... (Randy) > > Yes, now the compiler is accepting this (and letting me copy objects, > and, yes, getting rubbish in Self). I have no idea why it was not > compiling before. It just wasn't. And the messages indicated trouble > in the type. So, and because I know that Ada is a very sensitive lady, > I jumped to the (wrong) conclusion that the thing was illegal. If the compiler is letting you compile this: type T is record Self : access T := T'Unchecked_Access; end record; then the compiler is wrong, because this is illegal. The prefix of 'Unchecked_Access must be aliased, and the current instance of a non- limited record is not aliased. (Using 'Unchecked_Access instead of 'Access eliminates accessibility level checks, but the other rules that apply to 'Access, including the rule that it may apply only to an aliased view. See 3.10.2(23), 3.10(9) (and AARM 3.10(9.b)), 13.10(2-3). Using 'Unrestricted_Access may be OK, though; it's not part of the language, and GNAT gets to make whatever rules they like about whether it's legal. -- Adam