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-Thread: 103376,b99897135d6631cc X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Sat, 26 Jun 2004 10:44:33 -0500 Date: Sat, 26 Jun 2004 11:44:33 -0400 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: memory management and productivity References: <40d15023$1_1@baen1673807.greenlnk.net> <2jnh22F12nvieU2@uni-berlin.de> <40d69b1c$1_1@baen1673807.greenlnk.net> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 24.147.90.114 X-Trace: sv3-8Ry1UYL8lWzkWMRJY7bcje2qklNiHy5qakCGxeAPePYjXOskBAN/vOX4Z4BY+SEmXsEDbhL2p9ttmjI!yB56YoRP/mMqvFdn5qVaTKSipqyEuKSiNfRIixDIEBInzOuoT14YtZ5VJvdvAg== 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: g2news1.google.com comp.lang.ada:1925 Date: 2004-06-26T11:44:33-04:00 List-Id: Ole-Hjalmar Kristensen wrote: > Well, perhaps, but what Jano described is exactly like C++. > Doesn't the automatic finalization of an access to a controlled > object happen only when the *type* goes out of scope? No, as Martin's program shows, finalization occurs when the object or the type can no longer be referenced, no matter how that happens. This means you have to be a bit careful in designing your Finalize procedure. It may be called several times on the same object in complex cases. (The rule is that controlled objects in Ada are always finalized at least once. If you think about a subprogram that is doing clean-up when an exception occurs, you can see why the choice is between at least once and almost always.) But writing Finalize so that it is okay to call it multiple times is usually easy enough to do. Deallocating an object sets the pointer to it to null, and doesn't complain if given a null pointer as an argument. -- Robert I. Eachus "Reason and experience both forbid us to expect that national morality can prevail in exclusion of religious principles." -- George Washington