comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: How do I get this to work??
Date: 1999/01/10
Date: 1999-01-10T00:00:00+00:00	[thread overview]
Message-ID: <m3hfu0djxa.fsf@mheaney.ni.net> (raw)
In-Reply-To: Pine.BSF.4.05.9901091233230.7550-100000@shell5.ba.best.com

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 <bpr@shell5.ba.best.com> 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




  reply	other threads:[~1999-01-10  0:00 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-01-04  0:00 How do I get this to work?? Chris Warwick
1999-01-05  0:00 ` Tom Moran
1999-01-05  0:00 ` Chris Warwick
1999-01-05  0:00   ` Stephen Leake
1999-01-05  0:00     ` Tom Moran
1999-01-06  0:00       ` robert_dewar
1999-01-06  0:00         ` Tom Moran
1999-01-07  0:00           ` robert_dewar
1999-01-07  0:00             ` Tom Moran
1999-01-10  0:00               ` robert_dewar
1999-01-06  0:00         ` Larry Kilgallen
1999-01-06  0:00           ` Tom Moran
1999-01-06  0:00         ` Tom Moran
1999-01-07  0:00           ` robert_dewar
1999-01-07  0:00             ` Tom Moran
1999-01-10  0:00               ` robert_dewar
1999-01-10  0:00                 ` Tom Moran
1999-01-10  0:00                   ` robert_dewar
1999-01-10  0:00                     ` Pat Rogers
1999-01-10  0:00                     ` Tom Moran
1999-01-10  0:00                   ` robert_dewar
1999-01-06  0:00     ` robert_dewar
1999-01-06  0:00     ` Chris Warwick
1999-01-06  0:00       ` Tom Moran
1999-01-07  0:00       ` robert_dewar
1999-01-09  0:00         ` Chris Warwick
1999-01-09  0:00           ` Simon Wright
1999-01-10  0:00             ` robert_dewar
1999-01-11  0:00               ` Simon Wright
1999-01-16  0:00               ` Chris Warwick
1999-01-16  0:00                 ` Matthew Heaney
1999-01-16  0:00                   ` robert_dewar
1999-01-18  0:00                   ` Chris Warwick
1999-01-18  0:00                     ` Matthew Heaney
1999-01-18  0:00                     ` dennison
1999-01-18  0:00                     ` robert_dewar
1999-01-18  0:00                       ` dennison
1999-01-18  0:00                       ` Tucker Taft
1999-01-19  0:00                         ` Chris Warwick
1999-01-19  0:00                           ` Stephen Leake
1999-01-19  0:00                           ` robert_dewar
1999-01-20  0:00                             ` Jeff Carter
1999-01-20  0:00                               ` robert_dewar
1999-01-21  0:00                                 ` Chris Warwick
1999-01-19  0:00                           ` Tom Moran
1999-01-16  0:00                 ` robert_dewar
1999-01-18  0:00                   ` Chris Warwick
1999-01-18  0:00                     ` Matthew Heaney
1999-01-16  0:00                 ` Simon Wright
1999-01-09  0:00           ` Brian Rogoff
1999-01-10  0:00             ` Matthew Heaney [this message]
1999-01-07  0:00       ` Stephen Leake
1999-01-08  0:00         ` Simon Wright
1999-01-06  0:00   ` Simon Wright
1999-01-22  0:00   ` Nick Roberts
replies disabled

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