comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Nested declares, constant size arrays and clarity
Date: Thu, 4 Oct 2007 14:45:00 +0200
Date: 2007-10-04T14:39:09+02:00	[thread overview]
Message-ID: <1bykilw2jy8k3.1p7sr9xc5wl7i.dlg@40tude.net> (raw)
In-Reply-To: 87zlyz6rnt.fsf@ludovic-brenta.org

On Thu, 04 Oct 2007 13:33:10 +0200, Ludovic Brenta wrote:

> Mateusz Papiernik <mati@maticomp.net> writes:
> 
>> With strings I also have to work some way. As for now I'm using
>> Unbounded_Strings, because easy implementations of functions like
>> split (I'm parsing CSV file). Is it a good practice to use U_S, or
>> should I fall back to normal strings and fight with implementation?
> 
> I guess that depends on whether the input lines have a fixed length or
> not.  The main disadvantage of Unbounded_Strings are that they are
> much slower than regular Strings.

Others are lack of array interface, absence of slices, and inability to use
custom storage pools to allocate the body.

I never use Unbounded_String for parsing. The input line buffer can be
easily reused to accommodate varying strings. The right line boundary would
be not S'Last, but some variable <= S'Last. Alternatively a string slice
can be passed down to the parser. Something like that would be necessary to
do anyway to strip LF/CRs.

CSV formats are very easy to do with regular String, IMO much easier than
with Unbounded_String. You might take a look at

   http://www.dmitry-kazakov.de/ada/strings_edit.htm

No split or other forms of tokenizing is needed. Instead of that the fields
are scanned from left to right and the cursor position in the string) is
advanced to the position following the field. When it reaches the right
boundary, another line is read into the buffer, and the cursor is reset.
That's it.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2007-10-04 12:45 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-03 22:58 Nested declares, constant size arrays and clarity Mateusz Papiernik
2007-10-03 23:49 ` Ludovic Brenta
2007-10-04  8:49   ` Mateusz Papiernik
2007-10-04 11:33     ` Ludovic Brenta
2007-10-04 12:45       ` Dmitry A. Kazakov [this message]
2007-10-04 13:11         ` Mateusz Papiernik
2007-10-05  5:00           ` Jeffrey R. Carter
2007-10-05  4:58         ` Jeffrey R. Carter
2007-10-05  7:38           ` Dmitry A. Kazakov
2007-10-05 17:08             ` Jeffrey R. Carter
2007-10-05  4:54     ` Jeffrey R. Carter
2007-10-04  0:20 ` Jeffrey R. Carter
2007-10-04  8:51   ` Mateusz Papiernik
2007-10-05  2:45     ` Steve Whalen
2007-10-04  0:23 ` anon
replies disabled

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