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!news1.google.com!news.glorb.com!news.ecp.fr!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Self pointer in limited record Date: Fri, 7 Sep 2007 20:16:23 -0500 Organization: Jacob's private Usenet server Message-ID: References: <1183577468.034566.57830@n60g2000hse.googlegroups.com> <1188578849.187422.280620@50g2000hsm.googlegroups.com> <9fy1xoukz1e3$.h574sqmiauri$.dlg@40tude.net> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: jacob-sparre.dk 1189214008 19888 69.95.181.76 (8 Sep 2007 01:13:28 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Sat, 8 Sep 2007 01:13:28 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1896 Xref: g2news2.google.com comp.lang.ada:1809 Date: 2007-09-07T20:16:23-05:00 List-Id: "Dmitry A. Kazakov" wrote in message news:9fy1xoukz1e3$.h574sqmiauri$.dlg@40tude.net... > On Fri, 31 Aug 2007 16:47:29 -0000, amado.alves@gmail.com wrote: > > > Then you have seen illegal Ada code repeatedly. I wish this were > > possible myself. Or more simply: > > > > type T is -- limited or not > > Self : access T := T'Unchecked_Access; > > ... > > end; > > 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. Sure it can, just not written this way. The original question used Limited_Controlled, and thus you can initialize the pointer in the Initialize routine: procedure Initialize (Obj : in out T) is begin Self := Obj'Unchecked_Access; end Initialize; If the type is non-limited, you have to "fix" the self-pointer in Adjust. That's essentially how Claw does it. I personally prefer putting the code in Initialize (it's not so tricky that way, and you have more flexibility), but YMMV. Randy.