comp.lang.ada
 help / color / mirror / Atom feed
* Accessibility levels
@ 1999-02-04  0:00 adam
  1999-02-04  0:00 ` Tucker Taft
  1999-02-05  0:00 ` adam
  0 siblings, 2 replies; 3+ messages in thread
From: adam @ 1999-02-04  0:00 UTC (permalink / raw)


I'm having trouble understanding the rules in 3.10.2.  Given the
following program:

    procedure Test is

       type T is record
          Field : Integer;
       end record;

       procedure Inner (Param : access T) is
          type Access_T is access all T;
          Var : Access_T;
       begin
          Var := Param.all'access;      -- [1]
       end Inner;

    begin
       Block1:
       begin
          Block2:
          begin
             Block3:
             begin
                Block4:
                declare
                   XXX : aliased T;
                begin
                   Inner (XXX'access);
                end Block4;
             end Block3;
          end Block2;
       end Block1;
    end Test;


The statement [1] is legal (i.e. no compile-time error or runtime
exception) as long as the accessibility level of Param.all is not
deeper than that of Access_T.  The accessibility level of Param.all is
the same as that of Param's type (3.10.2(15)), which is an anonymous access
type, whose accessibility level is the same as that of XXX
(3.10.2(13)).  Is this correct so far?

However, I can't find any rules that explicitly say whether the
accessibility level of XXX is deeper than that of Access_T, or vice
versa.  Or, since neither is declared in a scope that encloses (or is
identical to) the other, does this mean that *neither* XXX nor
Access_T has a deeper accessibility level than the other?  I'm not
sure just what the rules are trying to say here.  It seems that from
the general principles in 3.10.2(3), statement [1] should be legal;
but since the rest of the section takes a lot of care to spell things
out with mathematical precision, I'm afraid I must be missing
something because I can't find a precise statement to cover this case.

Note that I'm not at all interested in whether anything's
accessibility level is *statically* deeper than anything else's.

Thanks in advance for your help.

                                -- Adam

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Accessibility levels
  1999-02-04  0:00 Accessibility levels adam
@ 1999-02-04  0:00 ` Tucker Taft
  1999-02-05  0:00 ` adam
  1 sibling, 0 replies; 3+ messages in thread
From: Tucker Taft @ 1999-02-04  0:00 UTC (permalink / raw)


adam@irvine.com wrote:

> I'm having trouble understanding the rules in 3.10.2.  Given the
> following program:
> 
>     procedure Test is
> 
>        type T is record
>           Field : Integer;
>        end record;
> 
>        procedure Inner (Param : access T) is
>           type Access_T is access all T;
>           Var : Access_T;
>        begin
>           Var := Param.all'access;      -- [1]
>        end Inner;
> 
>     begin
>        Block1:
>        begin
>           Block2:
>           begin
>              Block3:
>              begin
>                 Block4:
>                 declare
>                    XXX : aliased T;
>                 begin
>                    Inner (XXX'access);
>                 end Block4;
>              end Block3;
>           end Block2;
>        end Block1;
>     end Test;
> 
> The statement [1] is legal (i.e. no compile-time error or runtime
> exception) as long as the accessibility level of Param.all is not
> deeper than that of Access_T.  The accessibility level of Param.all is
> the same as that of Param's type (3.10.2(15)), which is an anonymous access
> type, whose accessibility level is the same as that of XXX
> (3.10.2(13)).  Is this correct so far?

Yes.

> However, I can't find any rules that explicitly say whether the
> accessibility level of XXX is deeper than that of Access_T, or vice
> versa.  Or, since neither is declared in a scope that encloses (or is
> identical to) the other, does this mean that *neither* XXX nor
> Access_T has a deeper accessibility level than the other? 

Accessibility level is defined (in 3.10.2(3)) based on *dynamic* 
nesting of scopes, so clearly Access_T is dynamically deeper than XXX,
when talking about the particular Access_T created by the
call on Inner from inside Block4.

When looking at source code one naturally thinks in terms of
"static" or "lexical" nesting, but when thinking about accessibility
levels you need to think about run-time/dynamic nesting.

> I'm not
> sure just what the rules are trying to say here.  It seems that from
> the general principles in 3.10.2(3), statement [1] should be legal;
> but since the rest of the section takes a lot of care to spell things
> out with mathematical precision, I'm afraid I must be missing
> something because I can't find a precise statement to cover this case.
> 
> Note that I'm not at all interested in whether anything's
> accessibility level is *statically* deeper than anything else's.

Ok, then don't think about what scopes "statically" enclose other
scopes, think about dynamic/run-time enclosure.

> Thanks in advance for your help.
> 
>                                 -- Adam

-Tuck

-- 
-Tucker Taft   stt@averstar.com   http://www.averstar.com/~stt/
Technical Director, Distributed IT Solutions  (www.averstar.com/tools)
AverStar (formerly Intermetrics, Inc.)   Burlington, MA  USA




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Accessibility levels
  1999-02-04  0:00 Accessibility levels adam
  1999-02-04  0:00 ` Tucker Taft
@ 1999-02-05  0:00 ` adam
  1 sibling, 0 replies; 3+ messages in thread
From: adam @ 1999-02-05  0:00 UTC (permalink / raw)


In article <79d460$abm$1@nnrp1.dejanews.com>,
  adam@irvine.com wrote:
> I'm having trouble understanding the rules in 3.10.2.  Given the
> following program: . . .

Never mind, I misread the word "dynamically" in 3.10.2(6).  That clears
everything up.

				-- Adam

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-02-05  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-02-04  0:00 Accessibility levels adam
1999-02-04  0:00 ` Tucker Taft
1999-02-05  0:00 ` adam

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