comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: functions, packages & characters
Date: Thu, 21 Feb 2002 20:57:55 -0600
Date: 2002-02-21T20:57:55-06:00	[thread overview]
Message-ID: <u7bcro6je1h519@corp.supernews.com> (raw)
In-Reply-To: u7b4d1bmd1f7ef@corp.supernews.com

Matthew Heaney wrote in message ...
>"Randy Brukardt" <randy@rrsoftware.com> wrote in message
>news:u7b1g6cooeo49@corp.supernews.com...
>> It is possible to write such a
>> Get_Line out of the primitives in Text_IO, but the result would be
>> unacceptably slow (because you would have to read a character at a
>> time - you can't use Get_Line because you can't tell between the case
of
>> a line which exactly fills the buffer and a line which is too long
and
>> does not -- but in the former case, the line terminator is skipped).
>
>This statement is incorrect.

Not exactly. This was true in Ada 83, but it was fixed circa 1985 (and
added to the validation tests a couple of years later [AI83-00050]).
There are a bunch of comments in our Text_IO implementation about this
change.

Still, I must be going senile: all I can imagine is that I "learned"
about Get_Line when this was true (at least in the compiler I used), and
haven't forgotten the "rule" even though it hasn't been true in a long
time.

>You can search comp.lang.ada at google.com for several posts I've
written on
>this very subject (search for "get_line").


Not interested; I've been using Get_Line since before you were born. :-)
(OK, not really...)

>   loop
>      Get_Line (Line, Last);
>      Append (Buffer, Line (Line'First .. Last));
>      exit when Last < Line'Last;
>   end loop;

This is, of course, the inefficiency that I was commenting on. This
would be slow, and would cause an awful lot of memory allocation and
deallocation, with the possible exception of the first iteration. It
would only be a good idea if the size of Line was larger than almost all
expected lines.

(Personally, I never use Unbounded strings, mainly because it took me
years to figure out how to use regular Ada strings effectively, and
Unbounded strings don't buy anything if you are used to doing that.)

                Randy Brukardt






  parent reply	other threads:[~2002-02-22  2:57 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-21  8:59 functions, packages & characters Christoph Grein
2002-02-21 18:07 ` Unversed Angel
2002-02-21 18:28   ` Hyman Rosen
2002-02-21 23:44     ` Randy Brukardt
2002-02-22  0:37       ` Matthew Heaney
2002-02-22  1:12         ` Matthew Heaney
2002-02-22  2:57         ` Randy Brukardt [this message]
2002-02-22 13:54           ` Marin David Condic
2002-02-23  1:10             ` Matthew Heaney
2002-02-25 15:47               ` Marin David Condic
2002-02-26 15:58                 ` Matthew Heaney
2002-02-25 19:37             ` Randy Brukardt
2002-02-25 20:49               ` Marin David Condic
2002-02-26  3:30               ` David Starner
2002-02-26 15:44                 ` Hyman Rosen
2002-02-26 21:43                   ` David Starner
2002-02-27  6:32                     ` Hyman Rosen
2002-02-28  3:55                       ` Chad R. Meiners
2002-02-28 18:44                         ` Hyman Rosen
2002-03-02  3:25                           ` Chad R. Meiners
2002-03-03  8:22                             ` Hyman Rosen
2002-03-03 17:50                               ` Chad R. Meiners
2002-03-01  2:08                         ` David Starner
2002-03-05 14:36                       ` Marin David Condic
2002-02-26  7:42               ` tmoran
2002-02-22 15:34           ` Matthew Heaney
2002-02-22  2:47       ` Jeffrey Carter
2002-02-22 13:41       ` Marin David Condic
2002-02-23  1:08         ` Matthew Heaney
2002-02-23  2:03         ` Jeffrey Carter
2002-02-22 16:27       ` Hyman Rosen
2002-02-21 23:49     ` unversedangel
2002-02-21 22:48   ` unversedangel
2002-02-21 23:14     ` Hyman Rosen
2002-02-22 14:11     ` Marin David Condic
  -- strict thread matches above, loose matches on Subject: below --
2002-02-21  0:16 Unversed Angel
2002-02-21  0:37 ` tmoran
2002-02-21  1:13   ` Unversed Angel
2002-02-21  2:53     ` tmoran
2002-02-21  8:25       ` Unversed Angel
2002-02-21 13:47         ` Marin David Condic
2002-02-22  0:22         ` tmoran
replies disabled

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