comp.lang.ada
 help / color / mirror / Atom feed
From: sbelmont700@gmail.com
Subject: Re: Access parameters and accessibility
Date: Tue, 16 Dec 2014 13:34:56 -0800 (PST)
Date: 2014-12-16T13:34:56-08:00	[thread overview]
Message-ID: <72048e0e-164a-4dce-8818-69454011a618@googlegroups.com> (raw)
In-Reply-To: <m6pdoq$tt3$1@speranza.aioe.org>

On Tuesday, December 16, 2014 8:57:50 AM UTC-5, Michael B. wrote:
> 
> I tried to find the paper you mentioned. But the only source I found is 
> the ACM website where I can buy it. Is this text somewhere publicly 
> available?
> 


I have a copy of the paper around, if you are that into things, but it's certainly not a casual read, nor does it really appeal to anyone except for the phony-tough or crazy-brave.  In any case, to go into a little more detail, the whole model is based on the idea of comparing the relative 'depths' (i.e. source code nesting), but that's a messy proposition because the depth is dynamic.  The relative example is as follows:

procedure Example6  is
   
   type T is ...;
   
   procedure P1(XP1 : access T) is
      type A is access T;
      Ptr: A := null;
      
      procedure P2(XP2: access T) is
      begin
         Ptr := A(XP2);
      end P2;
      
   begin
      P2(XP1);
   end P1;
   
   X : aliased T;

begin
   declare
      Y : aliased T:
    begin
      declare
         Z : aliased T;
       begin
         P1(X'Access);  
         P1(Y'Access);
         P1(Z'Access);   -- pass or fail?
       end;
    end;
end Example6;

In this example, note that all the objects X, Y and Z are all longer lived than type A, which conceptually only exists for the duration that P1 is executing, so each conversion should pass.  But also note that the "depths" of the objects that P1 (and consequently, P2) is getting are becoming progressively "deeper" as each declarative block gets elaborated.  The question then becomes what "depths" should the conversion in P2 be checking?  If the normal block-nesting level was used (where X is 1, Y is 2, and Z is 3), then Z would become evaluated as "too deep", since A would be 2 and Z would be 3, and you would get an erroneous program error doing the conversion.

So you can tweak things to say that in these special cases, you pass the *lower* of either the actual object depth or P1 itself.  So, in this case, now Z will pass the dynamic check since instead of getting the depth of Z, P2 gets the depth of P1 (since 1<3).  Now you can nest the declarative blocks a billion levels deep, and the proposed model still adheres to the LRM.

Again, it's important to stress that this is just one special case of one special part of just one possible implementation of one special-case language feature from twenty years ago, and that none of this should weigh heavily on your mind when learning or using Ada.  

-sb


  parent reply	other threads:[~2014-12-16 21:34 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-15 16:52 Access parameters and accessibility Michael B.
2014-12-15 17:54 ` Dmitry A. Kazakov
2014-12-15 18:48   ` Jeffrey Carter
2014-12-15 20:23     ` Michael B.
2014-12-15 21:02       ` Dmitry A. Kazakov
2014-12-16  1:10 ` sbelmont700
2014-12-16 13:57   ` Michael B.
2014-12-16 14:12     ` Georg Bauhaus
2014-12-16 21:34     ` sbelmont700 [this message]
2014-12-17 14:30       ` Michael B.
2014-12-17 15:41         ` sbelmont700
2014-12-18 17:48           ` Michael B.
2014-12-17 16:03         ` Adam Beneschan
2014-12-18 16:07           ` Michael B.
2014-12-16  7:45 ` Randy Brukardt
2014-12-16  8:48   ` Stefan.Lucks
2014-12-16 20:47     ` Randy Brukardt
2014-12-16 21:24       ` Georg Bauhaus
2014-12-16  9:08   ` Natasha Kerensikova
2014-12-16 10:00     ` Dmitry A. Kazakov
2014-12-16 14:57     ` Robert A Duff
2014-12-16 19:46   ` Michael B.
2014-12-16 20:59     ` Randy Brukardt
2014-12-17  7:02       ` Natasha Kerensikova
2014-12-17  8:28         ` Dmitry A. Kazakov
2014-12-17  9:06           ` Natasha Kerensikova
2014-12-17 22:58             ` Randy Brukardt
2014-12-17 22:25         ` Randy Brukardt
2014-12-18  0:47         ` Shark8
2014-12-17  2:02     ` Adam Beneschan
2014-12-17 23:18       ` Randy Brukardt
2014-12-18  0:56         ` Robert A Duff
2014-12-18  1:17           ` Randy Brukardt
2014-12-18  5:29             ` Shark8
2014-12-18 23:12             ` Randy Brukardt
2014-12-18  8:27         ` Dmitry A. Kazakov
2014-12-18 21:20           ` Randy Brukardt
2014-12-19 12:16 ` Michael B.
replies disabled

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