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!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns13feed!worldnet.att.net!attbi_s21.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Self pointer in limited record References: <1183577468.034566.57830@n60g2000hse.googlegroups.com> <1188578849.187422.280620@50g2000hsm.googlegroups.com> In-Reply-To: <1188578849.187422.280620@50g2000hsm.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 12.201.97.213 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s21 1188584805 12.201.97.213 (Fri, 31 Aug 2007 18:26:45 GMT) NNTP-Posting-Date: Fri, 31 Aug 2007 18:26:45 GMT Organization: AT&T ASP.att.net Date: Fri, 31 Aug 2007 18:26:45 GMT Xref: g2news2.google.com comp.lang.ada:1633 Date: 2007-08-31T18:26:45+00:00 List-Id: amado.alves@gmail.com wrote: > > type T is -- limited or not > Self : access T := T'Unchecked_Access; > ... > end; > > But the compiler will remind you that Unchecked_Access is not > available for types. > (It seems Ada is like most women: unnecessarily complicated and > difficult :-) What I have had occasion to use successfully is type R; task type TT (Parent : access R); type R is new Ada.Finalization.Limited_Controlled with record T : TT (Parent => R'access); ... end record; V : R; V.T.Parent designates V. Some points for this idiom: R must be limited, because it contains a limited component (the task). "The current instance of a limited tagged type, a protected type, a task type, or a type that has the reserved word limited in its full definition is also defined to be aliased." (ARM 3.10). This sort of thing may not work if R is not one of these cases (and so the current instance referred to by R in R'access is aliased); I haven't tried it. I usually have done this when revising others' existing code; there generally seem better designs when starting from scratch. -- Jeff Carter "Apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, the fresh water system, and public health, what have the Romans ever done for us?" Monty Python's Life of Brian 80