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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6c13cc000274246b X-Google-Attributes: gid103376,public From: Stephen Leake Subject: Re: Please Help. Date: 1997/09/17 Message-ID: <342005BE.5C4E@gsfc.nasa.gov>#1/1 X-Deja-AN: 273301009 References: <01bcbcde$f8a425c0$ca70fe8c@default> <5vaude$q20$1@goanna.cs.rmit.edu.au> <5vbiid$luu$1@goanna.cs.rmit.edu.au> <34197042.7CFC@gsfc.nasa.gov> <341D4041.4AF8@gsfc.nasa.gov> Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA Reply-To: Stephen.Leake@gsfc.nasa.gov Newsgroups: comp.lang.ada Date: 1997-09-17T00:00:00+00:00 List-Id: Robert Dewar wrote: > > Stephe said: > > < learn the fundamentals. On the other hand, if your learning control > structures, and you want to print a diagnostic message that is built > from several strings, Unbounded_Strings are nice.>> > > What's wrong with Put_Line ("value of x is " & Integer'Image (X) & ....) .. Ummm, nothing. I've been doing too much C++ lately, where such things are not available, and I have to use dynamic strings for this purpose. I guess I was thinking of that, not of the One True Way. Sigh. > > < out that using Unbounded_String does have a big downside? When you get > to teaching about dynamic memory allocation and managment, you could > point out that they've been doing it all along without thinking about > it, just like a lot of professional programmers!.>> > > What big downside? What's wrong with using Controlled types here, it is > certainly the intended and expected implementation! The downside is heap fragmentation, which will bite you just when it costs the most to fix. Controlled types can guarantee no dangling pointers; they do not guarantee no heap fragmentation. For that you need compacting storage pools (or very careful use of Unbounded_Strings). Is there a requirement in Ada 95 to document whether the Unbounded_Strings implementation is compacting? This would be useful information; I haven't seen it in Annex M for ObjectAda, but I don't believe I've read the whole thing. -- - Stephe