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=0.0 required=3.0 tests=BAYES_40,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.6 X-Received: by 2002:a05:620a:28d0:: with SMTP id l16mr15155546qkp.500.1638492565170; Thu, 02 Dec 2021 16:49:25 -0800 (PST) X-Received: by 2002:a25:40cc:: with SMTP id n195mr18651142yba.305.1638492565018; Thu, 02 Dec 2021 16:49:25 -0800 (PST) Path: eternal-september.org!reader02.eternal-september.org!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 2 Dec 2021 16:49:24 -0800 (PST) In-Reply-To: Injection-Info: google-groups.googlegroups.com; posting-host=92.40.193.184; posting-account=5K6RMgoAAADQeoHIOMi2dg5aYc0IVxGi NNTP-Posting-Host: 92.40.193.184 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: String Buffer From: Kevin Chadwick Injection-Date: Fri, 03 Dec 2021 00:49:25 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:63194 List-Id: > And note, that in most cases it is really thoughtless as the choice is=20 > made on the basis of how easy it is to declare a string component of a=20 > record type and then rewrite it.=20 >=20 > Later on throughout the rest of the program the user of Unbounded_String= =20 > will be consistently punished for that poor choice because normal string= =20 > operations are very uncomfortable with Unbounded_String. But that=20 > happens later. Right now and here, let us save a couple of code lines.=20 >=20 > So the simplest and most persuasive blanket statement is OK to dissuade= =20 > people from poor choices. I think I am glad that I am understanding this point about preferring strin= gs early on in my Ada usage. Of course it is very easy to convert to a Stri= ng as needed and whilst Randy mentioned yuck on "use" use, which I never us= e. I find package renames work well. I was thinking maybe you should never = propagate an unbounded but then I am sure there will be the occasional scen= ario, where you expect the caller most likely wants to append and the code = reads better without declares. As always...it depends..I guess? With regard to a String buffer. It just occurred to me that the reason boun= ded is more efficient than unbounded is because, you could consider the bou= nd max as a one time equivalent to strings.Builders grow(). In Go, I would = try to only call grow, once anyway.