comp.lang.ada
 help / color / mirror / Atom feed
From: Samuel Tardieu <sam@ada.eu.org>
Subject: Re: Freeing Pointers to classwide types
Date: 1998/09/25
Date: 1998-09-25T00:00:00+00:00	[thread overview]
Message-ID: <87k92sa1kr.fsf@zaphod.enst.fr> (raw)
In-Reply-To: 01bde866$1be8ed00$5330ea9e@UKP014459.logica.co.uk

>>>>> "Bob" == Bob Fletcher <fletcherr@logica.com> writes:

Bob> Really? Isn't the object that is created by the 'new' keyword
Bob> similar in nature to a C++ 'heap' variable, in that although the
Bob> pointer may go out of scope the object will not, and needs to be
Bob> explicitly destroyed?

In this case, the pointer *type* goes out of scope, so unless your
object is a task or unless you're using Unchecked_Conversion to
another pointer type (or whatever), your objet (which is passive if it 
isn't a task) is not going to be accessed anymore (you can't affect it 
to an outer access type since it will have a smallest accessibility level).

Example:

| procedure Q is
| 
|    type String_Ptr_Almost_Global is access all String;
| 
|    T : String_Ptr_Almost_Global;
| 
| begin
|    declare
| 	type String_Ptr_Local is access all String;
| 	S : String_Ptr_Local;
|    begin
| 	S := new String'("abcde");
| 	T := String_Ptr_Almost_Global (S);
|    end;
| end Q;

Compiling this with GNAT will lead to:

    13.       T := String_Ptr_Almost_Global (S);
                                             |
        >>> cannot convert local pointer to non-local access type

  Sam
-- 
Samuel Tardieu -- sam@ada.eu.org




  reply	other threads:[~1998-09-25  0:00 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-09-24  0:00 Freeing Pointers to classwide types joecool
1998-09-25  0:00 ` Tom Moran
1998-09-25  0:00   ` dewarr
1998-09-25  0:00     ` Tom Moran
1998-09-25  0:00       ` dewarr
1998-09-26  0:00     ` Tom Moran
1998-09-26  0:00       ` dewarr
1998-09-26  0:00         ` Tom Moran
1998-09-27  0:00           ` dewarr
1998-09-27  0:00             ` Tom Moran
1998-09-28  0:00               ` dewarr
1998-09-28  0:00                 ` Tom Moran
1998-09-28  0:00                   ` dewarr
1998-09-28  0:00                     ` Richard D Riehle
1998-09-28  0:00                       ` Pat Rogers
1998-09-29  0:00                       ` dewarr
1998-09-28  0:00                   ` dewarr
1998-09-28  0:00                     ` Tom Moran
1998-09-28  0:00                       ` Tom Moran
1998-09-28  0:00                         ` Brian Rogoff
1998-09-28  0:00                       ` Pat Rogers
1998-09-28  0:00                         ` Tom Moran
1998-09-28  0:00                           ` Pat Rogers
1998-09-29  0:00                           ` dewarr
1998-09-29  0:00                             ` Tom Moran
1998-09-30  0:00                               ` Tom Moran
1998-10-01  0:00                                 ` dewar
1998-10-01  0:00                                   ` Tom Moran
1998-10-01  0:00                                     ` Samuel Tardieu
1998-10-01  0:00                                       ` Tom Moran
1998-10-01  0:00                                         ` dennison
1998-10-01  0:00                                         ` Tucker Taft
1998-10-01  0:00                                           ` Tom Moran
1998-10-02  0:00                                           ` dewarr
1998-10-02  0:00                                             ` Larry Kilgallen
1998-10-02  0:00                                               ` dewarr
1998-10-02  0:00                                           ` dennison
1998-10-02  0:00                                             ` dewarr
1998-10-02  0:00                                         ` dewarr
1998-10-09  0:00                                           ` Matthew Heaney
1998-10-09  0:00                                             ` dennison
1998-10-09  0:00                                               ` Matthew Heaney
1998-10-01  0:00                                     ` dewarr
1998-10-01  0:00                                     ` dewarr
1998-10-01  0:00                                       ` Tom Moran
1998-10-09  0:00           ` Matthew Heaney
1998-09-25  0:00   ` Bob Fletcher
1998-09-25  0:00     ` Samuel Tardieu [this message]
1998-09-25  0:00     ` dennison
1998-10-09  0:00     ` Matthew Heaney
1998-10-12  0:00       ` Mats Weber
1998-10-12  0:00         ` Pat Rogers
1998-10-09  0:00   ` Matthew Heaney
1998-09-25  0:00 ` alan walkington
1998-09-26  0:00 ` Simon Wright
1998-10-09  0:00 ` Matthew Heaney
1998-10-09  0:00   ` Niklas Holsti
1998-10-10  0:00     ` Matthew Heaney
1998-10-11  0:00       ` Niklas Holsti
1998-10-11  0:00         ` Matthew Heaney
  -- strict thread matches above, loose matches on Subject: below --
1998-09-25  0:00 bpr5549
replies disabled

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