comp.lang.ada
 help / color / mirror / Atom feed
From: John Smith <yoursurrogategod@gmail.com>
Subject: Re: Question on bounded / unbounded strings
Date: Wed, 21 Sep 2016 19:10:11 -0700 (PDT)
Date: 2016-09-21T19:10:11-07:00	[thread overview]
Message-ID: <11ee98f5-d373-4c72-8562-c310cc76817d@googlegroups.com> (raw)
In-Reply-To: <nr8fgq$dc5$1@gioia.aioe.org>

On Tuesday, September 13, 2016 at 5:05:33 AM UTC-4, Dmitry A. Kazakov wrote:
> On 13/09/2016 10:46, Arie van Wingerden wrote:
> > Hi,
> >
> > for a long time I've been interested in Ada but hadn't played with it.
> >
> > Now I bit the bullet and I am trying to create a small (Windows) program
> > that:
> > 1) reads a string from STDIN (yet to do)
> > 2) fetches the contents of the PATH environment variable (done)
> > 3) splits that content in individual paths (???)
> > 4) tries to match the inputted string with part of each path (to do)
> > 5) outputs only the matched paths (to do)
> >
> > I found out the hard way that Ada is very strict about bounded versus
> > unbounded strings.
> > So I had to convert the output of 2) to an unbounded string, because I
> > could not know it's length in advance.
> >
> > Now I am a bit stuck splitting the string of paths;
> > I use GNAT.String_Split.Create, but it needs a (bounded) String as input.
> > However, I only have an unbounded string.
> >
> > QUESTION: How can I convert an unbounded string to a standard (bounded)
> > string?
> 
> Don't use either. For the thing you described (and for almost all cases) 
> standard String is a better, easier and safer choice. Bounded strings 
> are useless altogether. Unbounded string have very limited use.
> 
> P.S. Splitting/tokenization is just a wrong pattern for string 
> processing. You need not split strings at all. You just scan the string 
> from delimiter to delimiter marking beginning and end of the token and 
> then pass the substring further, e.g. building an ordered set of 
> [normalized] paths or directly matching them as they appear. It is 
> simpler, cleaner, safer and far more effective.
> 
> -- 
> Regards,
> Dmitry A. Kazakov
> http://www.dmitry-kazakov.de

Why would you say this?  I've found the ease with which you can append or manipulate unbounded strings to be very convenient.  Furthermore, I don't need to worry about computing the bound of my string.

From my experience unbounded string are very easy to work with.

But I genuinely am curious about your view on this and why.


  reply	other threads:[~2016-09-22  2:10 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 [this message]
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
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