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=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9a7ca14e457ad414 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-11-14 20:07:29 PST Newsgroups: comp.lang.ada Path: nntp.gmd.de!xlink.net!howland.reston.ans.net!gatech!bloom-beacon.mit.edu!news.bu.edu!inmet!spock!stt From: stt@spock.camb.inmet.com (Tucker Taft) Subject: Re: Ada 9X question: accessibility Message-ID: Sender: news@inmet.camb.inmet.com Organization: Intermetrics, Inc. References: <3a0hob$h5f@hopper.acm.org> Date: Mon, 14 Nov 1994 23:57:04 GMT Date: 1994-11-14T23:57:04+00:00 List-Id: In article <3a0hob$h5f@hopper.acm.org>, There can be only one wrote: >I was reading over the Ada 9X Reference Manual section on Access Types and >wanted to make sure I understood "accessibility" correctly. >I would appreciate any comments/confirmation on the following: We have recently rewritten this part of the manual in terms of "levels" to try to make it more "accessible" ;-). It was certainly pretty inscrutable in version 5.0. >procedure Example is > > type Access_Integer_Type is access all Integer; > Ptr_1 : Access_Integer_Type; > Int_1 : aliased Integer; > >begin > Local_Block: > declare > Ptr_2 : Access_Integer_Type; > Int_2 : aliased Integer; > begin > Ptr_1 := Int_1'Access; -- Legal. > Ptr_1 := Int_2'Access; -- Illegal. > Ptr_2 := Int_1'Access; -- Legal? Legal. > Ptr_2 := Int_2'Access; -- Illegal? Illegal. It makes no difference where Ptr_2 is declared, what matters is where the access type is declared. If you had declared another access type inside the declare block, and declared Ptr_3 to be of that type, then Ptr_3 := Int_2'Access; would be legal. > end Local_Block; >end Example; > >As I understand it, the first assignment >statement is legal, but the second one >is not because Int_2 is not dynamically accessible from the access type >Access_Integer_Type (and it's pretty obvious this would leave a dangling >reference). What about the last two assignment statements? As you guessed, it makes no difference where Ptr_2 is declared, what matters is where its type is declared. In the new terminology, the accessibility level of Int_2 is statically deeper than the accessibility level of Access_Integer_Type, so the 'Access is illegal. >Thanks in advance for your comments/help. > > > | | >David Papay | o | >papay@acm.org (preferred) | ^/--- | >dpapay@aol.com (alternate) | /> | > | | > | fleche! | S. Tucker Taft stt@inmet.com Ada 9X Mapping/Revision Team Intermetrics, Inc. Cambridge, MA 02138