comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.not.jrcarter@acm.not.spam.org>
Subject: Re: Why people wants to complicate code with Ada.Unchecked_Deallocation?
Date: Wed, 26 Jul 2006 21:28:15 GMT
Date: 2006-07-26T21:28:15+00:00	[thread overview]
Message-ID: <P7Rxg.1101345$xm3.664765@attbi_s21> (raw)
In-Reply-To: <44c7c3d3$0$47958$4fafbaef@reader3.news.tin.it>

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



  parent reply	other threads:[~2006-07-26 21:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-26 19:34 Why people wants to complicate code with Ada.Unchecked_Deallocation? fabio de francesco
2006-07-26 19:51 ` Georg Bauhaus
2006-07-26 19:56 ` Simon Wright
2006-07-26 21:28 ` Jeffrey R. Carter [this message]
2006-07-27 15:49   ` adaworks
2006-07-27 19:11     ` Jeffrey R. Carter
2006-07-27 22:52     ` Simon Wright
2006-07-27 23:28       ` Robert A Duff
2006-07-27  0:07 ` Peter C. Chapin
2006-07-27 11:54 ` gautier_niouzes
replies disabled

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