comp.lang.ada
 help / color / mirror / Atom feed
From: Kevin Chadwick <kevc3no4@gmail.com>
Subject: Re: String Buffer
Date: Thu, 2 Dec 2021 16:49:24 -0800 (PST)	[thread overview]
Message-ID: <f2418f34-c7af-49e9-901d-7621e1d224dan@googlegroups.com> (raw)
In-Reply-To: <sobepr$h88$1@gioia.aioe.org>

> 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.

I think I am glad that I am understanding this point about preferring strings early on in my Ada usage. Of course it is very easy to convert to a String as needed and whilst Randy mentioned yuck on "use" use, which I never use. 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 scenario, 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 bounded is more efficient than unbounded is because, you could consider the bound max as a one time equivalent to strings.Builders grow(). In Go, I would try to only call grow, once anyway.

  reply	other threads:[~2021-12-03  0:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-02 18:17 String Buffer Kevin Chadwick
2021-12-02 19:56 ` Jeffrey R.Carter
2021-12-02 20:15   ` Dmitry A. Kazakov
2021-12-02 21:06     ` Jeffrey R.Carter
2021-12-02 21:45       ` Dmitry A. Kazakov
2021-12-03  0:49         ` Kevin Chadwick [this message]
2021-12-03  5:25       ` Randy Brukardt
2021-12-03  8:31   ` ldries46
2021-12-02 20:51 ` Simon Wright
2021-12-03  8:11 ` Vadim Godunko
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox