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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,902bff0abea1083d X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns13feed!worldnet.att.net!attbi_s21.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" Organization: jrcarter at acm dot org User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Why people wants to complicate code with Ada.Unchecked_Deallocation? References: <44c7c3d3$0$47958$4fafbaef@reader3.news.tin.it> In-Reply-To: <44c7c3d3$0$47958$4fafbaef@reader3.news.tin.it> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 12.201.97.176 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s21 1153949295 12.201.97.176 (Wed, 26 Jul 2006 21:28:15 GMT) NNTP-Posting-Date: Wed, 26 Jul 2006 21:28:15 GMT Date: Wed, 26 Jul 2006 21:28:15 GMT Xref: g2news2.google.com comp.lang.ada:5953 Date: 2006-07-26T21:28:15+00:00 List-Id: fabio de francesco wrote: > > The following statement is from Cohen's "Ada as a second language": > > "Ada.Unchecked_Deallocation must be used with caution. As we shall see, it > can lead to subtle but devastating errors. If storage for allocated object > is plentiful, there is no point in complicating the program to keep track > of which allocated objects are no longer needed". > > Does it mean that, for safety sake, programmers should not care about memory > consumption? > > What do you think about this issue? It means that if a program won't run out of storage without unchecked deallocation, why bother putting it in? On the other hand, if a program will run out of storage without unchecked deallocation, it will fail unless you do deallocate storage, so you probably do want and need to put it in. In most cases, the use of access types and values can be hidden, so the opportunity for "devastating errors" is limited and not as big a concern as in C, where allocation and deallocation are usually scattered throughout the code. With the use of controlled types automatically performing deallocation during finalization, the opportunities for errors is limited further. So, in practice, it's not really that big of an issue. -- Jeff Carter "My mind is a raging torrent, flooded with rivulets of thought, cascading into a waterfall of creative alternatives." Blazing Saddles 89