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 22:45:32 +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="17672"; 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:63193 List-Id: On 2021-12-02 22:06, Jeffrey R.Carter wrote: > On 2021-12-02 21:15, Dmitry A. Kazakov wrote: >> >> 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. > > This is false. If you have the O(N) algorithm and it meets your > requirements, then using it is more efficient than implementing the > O(log N) algorithm. You have to show that it meets these requirements. The burden of proof is on you as you select an objectively inferior algorithm. Selecting a better algorithm is a safe choice under ill-defined conditions. > Unbounded_String is needed far less than many people think, but there > are application domains where it is much easier to achieve correctness > and clarity with a variable-length string abstraction than without. > Blanket statements about "efficiency" are dangerous for those working in > such domains. It is a good argument because introducing String requires more initial efforts in Ada than a thoughtless application Unbounded_String. And note, that in most cases it is really thoughtless as the choice is made on the basis of how easy it is to declare a string component of a record type and then rewrite it. Later on throughout the rest of the program the user of Unbounded_String will be consistently punished for that poor choice because normal string operations are very uncomfortable with Unbounded_String. But that happens later. Right now and here, let us save a couple of code lines. So the simplest and most persuasive blanket statement is OK to dissuade people from poor choices. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de