comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.acm.org>
Subject: Re: Using Ada.Containers.Vector and Limited Private types
Date: Sat, 12 Jul 2008 04:41:31 GMT
Date: 2008-07-12T04:41:31+00:00	[thread overview]
Message-ID: <%BWdk.194588$TT4.100135@attbi_s22> (raw)
In-Reply-To: <940db060-ef08-4e1c-9556-0514181183eb@j22g2000hsf.googlegroups.com>

Gene wrote:
> 
> Right.  I initially did it with UBS and changed it. Unbounded_String,
> at least in the GNAT implementation, is a super heavyweight.  In this
> case, you call Simple_Name to get a string and then convert it to an
> unbounded string.  In Ada 95 you'd have to convert back to a simple
> String for printing; fortunately that's fixed in 2005.  Nonetheless
> the syntax and the compiled code are both unsatisfying.  Barnes seems
> to agree:
> 
> ... conversion between bounded and unbounded strings and the raw type
> String is required rather a lot and is both ugly and inefficient.

Premature optimization is the root of all evil. In your little program, which 
gathers and displays some information, the overhead of Unbounded_String is not 
going to be a problem; in a larger system, only if it does prove to be the 
reason for not meeting the timing requirements should an alternative approach be 
considered.

I am currently working on a large, soft-real-time system which makes extensive 
use of Unbounded_String and uses GNAT Pro; we have no problem meeting our timing 
requirements.

> I do not find that relying on a simple new' and storage pool for
> release to be a very intimidating form of memory management.

There are many misconceptions about access types, storage pools, and memory 
management. I probably hold some of them. My understanding is that it is legal 
for the memory allocated for an access type such as you declared to not be 
reclaimed until the program ends (I welcome comments from the compiler writers 
out there). This is not a problem in your program, where the life of the access 
type ends at the same time as the life of the program. It probably would be a 
problem in a larger system that calls a similar subprogram repeatedly, expecting 
the memory to be reclaimed when the subprogram returns.

-- 
Jeff Carter
"Well, a gala day is enough for me. I don't think
I can handle any more."
Duck Soup
93



  reply	other threads:[~2008-07-12  4:41 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-05 11:53 Using Ada.Containers.Vector and Limited Private types Dale Stanbrough
2008-07-05 15:42 ` george.priv
2008-07-06 18:09 ` Gene
2008-07-06 19:18   ` Dmitry A. Kazakov
2008-07-07 13:29     ` Gene
2008-07-07 14:15       ` Dmitry A. Kazakov
2008-07-07 18:39         ` Gene
2008-07-10  0:16   ` Dale Stanbrough
2008-07-10  7:31     ` Dmitry A. Kazakov
2008-07-10 22:59     ` Gene
2008-07-11 22:06       ` Jeffrey R. Carter
2008-07-12  2:45         ` Gene
2008-07-12  4:41           ` Jeffrey R. Carter [this message]
2008-07-13 15:30             ` Gene
2008-07-13 18:10               ` Jeffrey R. Carter
2008-07-16 21:23               ` Simon Wright
2008-07-12  8:02           ` Dmitry A. Kazakov
2008-07-12  7:53       ` Dmitry A. Kazakov
replies disabled

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