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,86ec22e070e319c0 X-Google-Attributes: gid103376,public From: Matthew Heaney Subject: Re: How do I get this to work?? Date: 1999/01/10 Message-ID: #1/1 X-Deja-AN: 430719357 Sender: matt@mheaney.ni.net References: <76s0dp$1v4$1@nntp3.uunet.ca> <76tbvv$ba5$1@nntp3.uunet.ca> <770ifd$qui$1@goblin.uunet.ca> <771bl9$sla$1@nnrp1.dejanews.com> NNTP-Posting-Date: Sat, 09 Jan 1999 16:55:26 PDT Newsgroups: comp.lang.ada Date: 1999-01-10T00:00:00+00:00 List-Id: All the compiler is doing when it forbids 'Access is to tell the programmer that it, the compiler, can't make guarantees about the lifetime of designated object. There is nothing magical about 'Unchecked_Access. When you use it, you are not being bad or naughty. It simply means that the programmer is taking the responsibility to guarantee that the designated object lives longer than the access object, instead of relying on the compiler to provide this guarantee. The reasoning that is required in order to prove that an object lives long enough, is not unlike the mental activity that must be performed by the programmer to reason that a loop terminates, or indeed that an algorithm delivers a correct result. Sometimes, thinking is required. It's the same process that C programmers have to follow, whenever they designate an object via a pointer (which is often), because the language itself offers no help. Brian Rogoff writes: > On Sat, 9 Jan 1999, Chris Warwick wrote: > > In article <771bl9$sla$1@nnrp1.dejanews.com>, robert_dewar@my-dejanews.com wrote: > > > > >You can't have it both ways, If you insist on structuring > > >your program in a manner that leaves it open to the > > >possibilities of dangling pointers, then you have to use > > >Unchecked_Access. > > > > I guess this where I get confused. If I want to pass a pointer amoungst these > > functions/procedures I have to define the type at the package level. As a > > result there is no way for someone to define an instance of the pointer at a > > lower level, i.e., as a local variable within a procedure. Another way to get > > I'm jumping into the middle of this, so I don't have the context, but one > trick I use to define access types at a lower level is to define the > access types in a generic package and instantiate them in the scope that > I need them. This trick is especially useful with access to subprogram > types, which don't permit an Unchecked_Access. > > > I've got it working... My uneasyness stems from the fact that when I ran into > > unchecked_conversion I was able to get someone to explain to me how it really > > was "supposed" to work, and once I understood, I agreed. Thus far I still do > > not understand how a package can export a "useful" pointer definition... > > By making the package (a parameterless, if necessary) generic, and > instantiating it where you need it? > > -- Brian