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 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2e81f53ebf2045a3 X-Google-Attributes: gid103376,public From: Tucker Taft Subject: Re: Accessibility levels Date: 1999/02/04 Message-ID: <36BA2116.1FCB1E90@averstar.com>#1/1 X-Deja-AN: 440766186 Content-Transfer-Encoding: 7bit Sender: news@inmet.camb.inmet.com (USENET news) X-Nntp-Posting-Host: houdini.burl.averstar.com References: <79d460$abm$1@nnrp1.dejanews.com> Content-Type: text/plain; charset=us-ascii Organization: AverStar (formerly Intermetrics) Burlington, MA USA Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-02-04T00:00:00+00:00 List-Id: 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