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,6c43f45c2ab47c51 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns14feed!worldnet.att.net!attbi_s22.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Using Ada.Containers.Vector and Limited Private types References: <8ff4c6c2-9892-463e-bdfd-1f7bfd78d607@s50g2000hsb.googlegroups.com> <4c5bfeb0-daa0-45e4-82f0-eebabda565e9@d45g2000hsc.googlegroups.com> <6QQdk.194211$TT4.37376@attbi_s22> <940db060-ef08-4e1c-9556-0514181183eb@j22g2000hsf.googlegroups.com> In-Reply-To: <940db060-ef08-4e1c-9556-0514181183eb@j22g2000hsf.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <%BWdk.194588$TT4.100135@attbi_s22> NNTP-Posting-Host: 12.201.97.213 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s22 1215837691 12.201.97.213 (Sat, 12 Jul 2008 04:41:31 GMT) NNTP-Posting-Date: Sat, 12 Jul 2008 04:41:31 GMT Organization: AT&T ASP.att.net Date: Sat, 12 Jul 2008 04:41:31 GMT Xref: g2news2.google.com comp.lang.ada:6847 Date: 2008-07-12T04:41:31+00:00 List-Id: 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