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.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e94a7e4f6f888766 X-Google-Attributes: gid103376,public From: Ted Dennison Subject: Re: Self-referential types Date: 1999/10/12 Message-ID: <7tvgud$qh7$1@nnrp1.deja.com>#1/1 X-Deja-AN: 535804348 References: <7ttb4a$8mq$1@nnrp1.deja.com> <3802597B.9205AEE8@averstar.com> X-Http-Proxy: 1.0 bx6.deja.com:80 (Squid/1.1.22) for client 204.48.27.130 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Tue Oct 12 14:34:54 1999 GMT X-MyDeja-Info: XMYDJUIDtedennison Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.6 [en] (WinNT; I) Date: 1999-10-12T00:00:00+00:00 List-Id: In article <3802597B.9205AEE8@averstar.com>, Tucker Taft wrote: > Ted Dennison wrote: > > > > Below is a code sample that is taken directly from Cohen's AAASL, > > section 11.8.3: > > > > procedure Test is > > > > type Cell_Type; > > > > type List_Type is access all Cell_Type; > > > > type Cell_Type is > > limited record > > Contents_Part : String (1..20); > > Next_Cell_Part : List_Type := Cell_Type'Access; > > Previous_Cell_Part : List_Type := Cell_Type'Access; > > end record; > invokes the various accessibility rules. In particular, when > inside the definition of a type, 'Access is presumed > to have an accessibility level deeper than that of the enclosing type, > meaning it is also deeper than List_Type. Note that there is > nothing preventing the values of next and previous being copied > into global variables, whereas you might have a local object of type > Cell_Type. OK. After masticating on this parargraph for a while, I think what you are saying is that I theoreticly could do this: Global : List_Type; procedure Local is Cell : Cell_Type; begin Global := Cell.Next_Cell_Part; end Local; ..and then after a call to Local, I now have in Global a pointer into unallocated stack space. I think what was confusing me was that I'm used to thinking about accessability levels in record *objects*, not types. But I can't speak for what was confusing Cohen. :-) > To avoid the use of "'Unchecked_Access" you could simply default > initialize to "null," You could define a separate function to do the ..or use a second null record with an access discriminant, as I have seen done elsewhere. -- T.E.D. Sent via Deja.com http://www.deja.com/ Before you buy.