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,ed6a891101ff4e06 X-Google-Attributes: gid103376,public From: Samuel Tardieu Subject: Re: Freeing Pointers to classwide types Date: 1998/09/25 Message-ID: <87k92sa1kr.fsf@zaphod.enst.fr>#1/1 X-Deja-AN: 394692388 Content-Transfer-Encoding: 8bit References: <1ftmFTC69GA.191@samson.airnet.net> <360b26a1.41575272@SantaClara01.news.InterNex.Net> <01bde866$1be8ed00$5330ea9e@UKP014459.logica.co.uk> Mail-Copies-To: sam@ada.eu.org Content-Type: text/plain; charset=iso-8859-1 Organization: TELECOM Paris Mime-Version: 1.0 User-Agent: Gnus/5.070032 (Pterodactyl Gnus v0.32) XEmacs/21.2(beta1) (Aeolus) Newsgroups: comp.lang.ada Date: 1998-09-25T00:00:00+00:00 List-Id: >>>>> "Bob" == Bob Fletcher 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