From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!aioe.org!3s634R+rSk3f11Qz2WJrTw.user.46.165.242.91.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: String Buffer Date: Thu, 2 Dec 2021 21:15:11 +0100 Organization: Aioe.org NNTP Server Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: gioia.aioe.org; logging-data="5841"; posting-host="3s634R+rSk3f11Qz2WJrTw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader02.eternal-september.org comp.lang.ada:63189 List-Id: On 2021-12-02 20:56, Jeffrey R.Carter wrote: > On 2021-12-02 19:17, Kevin Chadwick wrote: >> >> Unbounded is said to be inefficient because it re-allocates. >> >> In any case avoiding unbounded strings is almost certainly in the >> realm of premature optimisation I see it as a design question. Code that modifies a string as a whole is most likely broken. Unbounded_String property of varying length is not needed except for very special cases, like passing parameters where no result is allowed, e.g. in the task entries. Most, if not all such cases are Ada language design deficiencies. Normally there should be no need for Unbounded_String. > In the absence of such context, any claims of "inefficiency" (and > especially blanket claims such as "Unbounded_String is inefficient") > simply demonstrate the speaker's incompetence. It is true only to a certain degree. When comparing algorithms it is valid to claim inefficiency without any context if computational complexity sufficiently differs. For example, an O(N) algorithm is unquestionably inefficient comparing to O(log N) one. I leave marginal cases of very small N. Unbounded_String uses storage pool and that is a qualitative difference that requires in any context. For very large text buffers they are unusable either. Again, it is a design question, any time I see Unbounded_String alarm bells start ringing. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de