comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Question on bounded / unbounded strings
Date: Wed, 28 Sep 2016 15:55:37 -0500
Date: 2016-09-28T15:55:37-05:00	[thread overview]
Message-ID: <nshanj$5bh$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: 625e3d31-1a45-4308-8122-e7ccac0b3e13@googlegroups.com

"Maciej Sobczak" <see.my.homepage@gmail.com> wrote in message 
news:625e3d31-1a45-4308-8122-e7ccac0b3e13@googlegroups.com...

>Sorry Dmitry, but I don't think that this discussion is interesting for 
>anybody else here.

I find it interesting, to see you defend the indefensible. ;-)

Needless to say, I agree with Dmitry. For instance, Split (in terms of a 
string type, which is what is being talked about) is an operation that takes 
one string and produces several. (Getting substrings is a different 
operation altogether.) You very rarely want an actual Split operation (which 
is all Dmitry said initially); you're much more likely to use some sort of 
substring of the original string.

Ada bounded strings are nearly useless; as Dmitry said, you rarely have a 
hard bound and the fact that all of the objects of the type have to have the 
same bound just compounds the problem. Just forget them and use either 
Unbounded_Strings or String.

And the Ada.Strings packages are filled with cool subprograms that are 
almost never used. Even if you remember one exists, you have to go look it 
up to figure out the name and parameters and usage -- by that time, you 
could have written the operation yourself with basic operations (admittedly, 
with a slightly higher chance of introducing bugs).

I wrote my spam filter exclusively with unbounded strings in part to 
demostrate how much easier that would be. Needless to say, that failed 
miserably. I did get the experience I was looking for, but it was mostly 
bad. :-)

There is one use for unbounded strings that comes up in the spam filter that 
probably couldn't have been usefully programmed any other way. One wants to 
search the text of messages for problem phrases unencombered by irrelvant 
stuff (like encodings and line endings). I did that by putting the decoded 
(and stripped of HTML markup) text into an unbounded string, and then search 
that. That is way cheaper than searching multiple lines and somehow allowing 
blanks to be matched by line ends as well as separately dealing with 
decoding and markup.

Still, this seems to be a rare case; I've never encountered anything else 
like it. Most of the operations I encounter would be better off written (in 
Ada, no one here should care about any other language. ;-) using plain 
String. The extra work is usually not that much (and most of the cool 
operations are available for plain String in Ada.Strings.Fixed, in case one 
is exacly what is needed - I use Index and Find_Token a lot).

                                   Randy.



  parent reply	other threads:[~2016-09-28 20:55 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-13  8:46 Question on bounded / unbounded strings Arie van Wingerden
2016-09-13  9:04 ` Dmitry A. Kazakov
2016-09-22  2:10   ` John Smith
2016-09-22  7:24     ` Dmitry A. Kazakov
2016-09-22  9:01       ` J-P. Rosen
2016-09-22  9:53         ` Dmitry A. Kazakov
2016-09-22 10:58           ` G.B.
2016-09-22 12:05             ` Dmitry A. Kazakov
2016-09-22 14:14               ` G.B.
2016-09-22 17:18                 ` Dmitry A. Kazakov
2016-09-22 11:08           ` J-P. Rosen
2016-09-22 12:05             ` Dmitry A. Kazakov
2016-09-22 13:18           ` Maciej Sobczak
2016-09-22 13:52             ` Dmitry A. Kazakov
2016-09-22 14:51               ` Maciej Sobczak
2016-09-22 17:13                 ` Dmitry A. Kazakov
2016-09-23  5:50                   ` Maciej Sobczak
2016-09-23  6:36                     ` Simon Wright
2016-09-23  7:48                       ` Dmitry A. Kazakov
2016-09-28 20:55                     ` Randy Brukardt [this message]
2016-09-23 23:58       ` John Smith
2016-09-24  7:52         ` Dmitry A. Kazakov
2016-09-24 16:25           ` John Smith
2016-09-24 17:44             ` Dmitry A. Kazakov
2016-09-24 18:33               ` John Smith
2016-09-24 18:37               ` John Smith
2016-09-24 18:59               ` John Smith
2016-09-25  8:50                 ` Dmitry A. Kazakov
2016-09-25 23:35                   ` brbarkstrom
2016-09-26  7:28                     ` Dmitry A. Kazakov
2016-09-26 12:39                       ` brbarkstrom
2016-09-28 21:09             ` Randy Brukardt
2016-09-30  7:59               ` Björn Lundin
2016-09-13  9:35 ` gautier_niouzes
2016-09-13 10:41 ` Alejandro R. Mosteo
2016-09-13 17:41 ` Jeffrey R. Carter
2016-09-13 17:59 ` Björn Lundin
2016-09-14 11:23 ` Arie van Wingerden
2016-09-14 12:26   ` Arie van Wingerden
2016-09-14 12:28   ` Arie van Wingerden
2016-09-14 12:57 ` Arie van Wingerden
2016-09-14 19:39   ` Jeffrey R. Carter
2016-09-17 16:35     ` Arie van Wingerden
2016-09-16 14:43 ` Olivier Henley
2016-09-17 16:35   ` Arie van Wingerden
replies disabled

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