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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,56131a5c3acc678e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-03 17:23:56 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!crtntx1-snh1.gtei.net!news.gtei.net!newsfeed1.easynews.com!easynews.com!easynews!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!intern1.nntp.aus1.giganews.com!nntp.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Wed, 03 Dec 2003 19:23:54 -0600 Date: Wed, 03 Dec 2003 20:23:53 -0500 From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Question about OO programming in Ada References: <8urxb.19482$sb4.18182@newsread2.news.pas.earthlink.net> <1792884.HtYz4Yv8lY@linux1.krischik.com> <1070466281.168920@master.nyc.kbcfp.com> <1070490862.478119@master.nyc.kbcfp.com> In-Reply-To: <1070490862.478119@master.nyc.kbcfp.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 24.34.214.193 X-Trace: sv3-qz0bonKLs1v05MF1s9FwqhgqUtzOtU+ojsELEq44cuZjtguoKhL1dFcXnRV7+QxnPuHes2O1Rd9Vzbx!jE8mnq0y3ZV0gIP5u2d+PJFaV6quxroGn70UCh4oOot6C1fgVs8ar2gSPMoOOw== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 Xref: archiver1.google.com comp.lang.ada:3123 Date: 2003-12-03T20:23:53-05:00 List-Id: Hyman Rosen wrote: > Not on a pointer field within the object, but on the object itself. I'm very confused about why Hyman is confused. Making a copy of an access value in Ada, and calling Free for both the original and the copy is bad juju. Calling Free twice, or twenty times and passing the only the original access object is never a problem. Ah, I think I get it. In C there are many occasions where a function will return a heap object, and it is up to the caller to free the memory. The returned value can be a copy of the original pointer, so in C it is relatively common to free a copy of the original heap pointer. That may be what is confusing Hyman. In Ada is it very rare, and usually an error if you call Free for an object or value that was not assigned a value by new. Normally in Finalize procedures this is a record parameter. Freeing the entire record that was the parameter of a Finalize procedure is possible to write, but you end up assigning Foo'Access to something then freeing it. (If you try to call Free on a access discriminant, it won't work.) As the previous paragraph says, to any Ada programmer that looks like big trouble, and it is. -- Robert I. Eachus 100% Ada, no bugs--the only way to create software.