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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,64b29dfa2220a59f X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!r34g2000hsd.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: Reserve_Capacity for Unbounded_String? Date: Wed, 25 Jul 2007 23:24:03 -0700 Organization: http://groups.google.com Message-ID: <1185431043.649372.223760@r34g2000hsd.googlegroups.com> References: <1185134043.892012.217560@n2g2000hse.googlegroups.com> <1185203238.701948.307410@m37g2000prh.googlegroups.com> <1185395844.104043.194340@o61g2000hsh.googlegroups.com> <46a7c85b$0$3827$9b4e6d93@newsspool4.arcor-online.net> NNTP-Posting-Host: 137.138.37.241 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1185431043 3596 127.0.0.1 (26 Jul 2007 06:24:03 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 26 Jul 2007 06:24:03 +0000 (UTC) In-Reply-To: <46a7c85b$0$3827$9b4e6d93@newsspool4.arcor-online.net> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.12) Gecko/20070601 Red Hat/1.5.0.12-0.1.slc3 Firefox/1.5.0.12,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: r34g2000hsd.googlegroups.com; posting-host=137.138.37.241; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 Xref: g2news2.google.com comp.lang.ada:1191 Date: 2007-07-25T23:24:03-07:00 List-Id: On 26 Lip, 00:06, Georg Bauhaus wrote: > > Building a string by appending small chunks to the end seems to be a > > common practice. Optimizing the library for this case is a wise > > implementation strategy. > > Is there some material on this? I'm wondering whether concatenating > strings is more common in languages where strings are lists, or at > least not plain arrays. Why should that matter? Do you think that the implementation details like this one can influence the way people *think* about strings in their programs? We read text from beginning to the end, acquiring information. It seems obvious that, conversely, adding information to the string is best achieved by adding more characters to the end, at least when human-readable content is involved. This is what I'm actually doing when typing this post. I append characters to what is already there (let's forget correcting typos - automated procedures don't have to do this). Coming back to your question about different languages - it is not the programmer who should adapt his way of building the strings according to how the string is implemented internally in a given language (note that many languages don't even specify it). It is the language that should provide the implementation that is best fitted to how programmers express their algorithms. Why do you think Java added StringBuilder to its library? Because the immutable String didn't quite cut it. -- Maciej Sobczak http://www.msobczak.com/