comp.lang.ada
 help / color / mirror / Atom feed
From: Tucker Taft <stt@averstar.com>
Subject: Re: Accessibility levels
Date: 1999/02/04
Date: 1999-02-04T00:00:00+00:00	[thread overview]
Message-ID: <36BA2116.1FCB1E90@averstar.com> (raw)
In-Reply-To: 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:
> 
>     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




  reply	other threads:[~1999-02-04  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-04  0:00 Accessibility levels adam
1999-02-04  0:00 ` Tucker Taft [this message]
1999-02-05  0:00 ` adam
replies disabled

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