comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison <dennison@telepath.com>
Subject: Re: Self-referential types
Date: 1999/10/12
Date: 1999-10-12T00:00:00+00:00	[thread overview]
Message-ID: <7tvgud$qh7$1@nnrp1.deja.com> (raw)
In-Reply-To: 3802597B.9205AEE8@averstar.com

In article <3802597B.9205AEE8@averstar.com>,
  Tucker Taft <stt@averstar.com> 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, <type_name>'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.




  parent reply	other threads:[~1999-10-12  0:00 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <7ttb4a$8mq$1@nnrp1.deja.com>
1999-10-12  0:00 ` Self-referential types Vladimir Olensky
1999-10-12  0:00   ` Matthew Heaney
1999-10-12  0:00     ` Richard D Riehle
1999-10-12  0:00     ` news.oxy.com
1999-10-12  0:00       ` Ted Dennison
1999-10-12  0:00         ` Stanley R. Allen
1999-10-13  0:00           ` Ted Dennison
1999-10-13  0:00         ` Vladimir Olensky
1999-10-14  0:00         ` Multiple Inheritance in Ada 95 [was Re: Self-referential types] Tucker Taft
1999-10-12  0:00       ` Self-referential types Matthew Heaney
1999-10-12  0:00     ` Ted Dennison
1999-10-12  0:00       ` Matthew Heaney
1999-10-12  0:00     ` Robert I. Eachus
1999-10-12  0:00       ` Matthew Heaney
1999-10-13  0:00         ` Ted Dennison
1999-10-13  0:00           ` Matthew Heaney
1999-10-13  0:00         ` Vladimir Olensky
1999-10-13  0:00           ` Vladimir Olensky
1999-10-18  0:00           ` Robert Dewar
1999-10-18  0:00             ` Vladimir Olensky
1999-10-18  0:00             ` Laurent Guerby
1999-10-13  0:00         ` Robert I. Eachus
1999-10-13  0:00           ` Brian Rogoff
1999-10-15  0:00             ` Robert I. Eachus
1999-10-15  0:00               ` Marin David Condic
1999-10-15  0:00                 ` Robert I. Eachus
1999-10-18  0:00                   ` Robert Dewar
1999-10-19  0:00                     ` Robert I. Eachus
1999-10-18  0:00               ` Robert Dewar
1999-10-18  0:00                 ` Brian Rogoff
1999-10-18  0:00                 ` Ed Falis
1999-10-19  0:00                   ` Robert Dewar
     [not found]               ` <7u86su$o5v$1@nntp8.atl.mindspring.net>
1999-10-18  0:00                 ` Robert I. Eachus
1999-10-22  0:00                   ` Richard D Riehle
1999-10-22  0:00                     ` Robert I. Eachus
     [not found]               ` <slrn80fl9f.68j.aidan@skinner.demon.co.uk>
1999-10-19  0:00                 ` Wes Groleau
1999-10-21  0:00                   ` Robert Dewar
1999-10-21  0:00                     ` Larry Kilgallen
1999-10-21  0:00                     ` Comments (was: Self-referential types) Wes Groleau
1999-10-21  0:00                       ` Ehud Lamm
1999-10-22  0:00                         ` Ted Dennison
1999-10-23  0:00                           ` Ehud Lamm
1999-10-23  0:00                         ` Robert Dewar
1999-10-23  0:00                           ` Ehud Lamm
1999-10-23  0:00                             ` Comments Georg Bauhaus
1999-10-24  0:00                               ` Comments Ehud Lamm
1999-10-26  0:00                                 ` Comments Robert I. Eachus
1999-10-28  0:00                                   ` Comments Jerry van Dijk
1999-10-28  0:00                                     ` Comments Ted Dennison
1999-10-25  0:00                             ` Comments (was: Self-referential types) Wes Groleau
1999-10-23  0:00                       ` M.
     [not found]                       ` <Pine.A41.3.96-heb-2.07.991021191504.30582K-100000@pluto.mscc.huji. <381477c9.e1388ff3@ftw.rsc.raytheon.com>
1999-10-25  0:00                         ` Larry Kilgallen
1999-10-21  0:00                     ` Self-referential types Jean-Pierre Rosen
1999-10-21  0:00                       ` Robert Dewar
1999-10-22  0:00                     ` Richard D Riehle
1999-10-23  0:00                       ` Robert A Duff
1999-10-23  0:00                         ` Richard D Riehle
1999-10-24  0:00                       ` Michel DELARCHE
1999-10-12  0:00 ` Robert A Duff
     [not found] ` <3802597B.9205AEE8@averstar.com>
1999-10-12  0:00   ` Ted Dennison [this message]
1999-10-12  0:00     ` Matthew Heaney
1999-10-13  0:00       ` Ted Dennison
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox