From: "Steve" <nospam_steved94@comcast.net>
Subject: Re: Get_Line problem (GNAT bug?)
Date: Wed, 6 Dec 2006 19:34:42 -0800
Date: 2006-12-06T19:34:42-08:00 [thread overview]
Message-ID: <C-6dnavmyanjFurYnZ2dnUVZ_rSdnZ2d@comcast.com> (raw)
In-Reply-To: el6jss$268$1@cernne03.cern.ch
"Maciej Sobczak" <no.spam@no.spam.com> wrote in message
news:el6jss$268$1@cernne03.cern.ch...
[snip]
>
> Any thoughts?
>
You have run across what I consider to be a weakness in the standard Text_IO
library, it is one of the few things I find really annoying about Ada, which
I really like otherwise.
In Ada you can't write a simple program to read and process lines in a text
file that looks something like:
while not End_Of_File( inFile ) loop
Get_Line( inFile, Input_Buffer, Count );
Process_Line( Input_Buffer( 1 .. Count ) );
end loop;
The problem is that Get_Line reads a line of text into a string buffer and
returns the count of characters read. The "line of text" is defined by the
next sequential characters from the current position of the file up to the
next line terminator. If the last character in the file doesn't happen to
be a line termnator an End_Error exception is raised.
It would be much more useful if Get_Line read from the current position to
the next line terminator OR end of file. This is the way the other
languages I have used work. Because of the way the Get_Line function works
you have to jump through a bunch of inefficient hoops like reading one
character at a time in order to get the desired behavior. In my opinion
raising an exception when the end of file doesn't have an end of line
terminator should be the exceptional case and not the rule.
I suspec this is the same problem you're running into with your interactive
program.
Steve
(The Duck)
> --
> Maciej Sobczak : http://www.msobczak.com/
> Programming : http://www.msobczak.com/prog/
next prev parent reply other threads:[~2006-12-07 3:34 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-06 14:25 Get_Line problem (GNAT bug?) Maciej Sobczak
2006-12-06 18:06 ` Adam Beneschan
2006-12-06 20:34 ` Gautier
2006-12-06 21:47 ` Dmitry A. Kazakov
2006-12-06 23:40 ` Adam Beneschan
2006-12-07 0:02 ` Björn Persson
2006-12-07 1:09 ` Adam Beneschan
2006-12-07 1:28 ` Björn Persson
2006-12-07 5:00 ` Jeffrey R. Carter
2006-12-07 8:26 ` Maciej Sobczak
2006-12-07 9:21 ` Jean-Pierre Rosen
2006-12-07 13:35 ` Ludovic Brenta
2006-12-07 22:23 ` Robert A Duff
2006-12-07 10:22 ` Dmitry A. Kazakov
2006-12-07 14:51 ` Maciej Sobczak
2006-12-07 16:29 ` Dmitry A. Kazakov
2006-12-08 8:22 ` Maciej Sobczak
2006-12-07 22:50 ` Robert A Duff
2006-12-08 0:13 ` Randy Brukardt
2006-12-08 4:04 ` Larry Kilgallen
2006-12-08 9:11 ` Dmitry A. Kazakov
2006-12-07 9:14 ` Jean-Pierre Rosen
2006-12-07 3:34 ` Steve [this message]
2006-12-07 17:42 ` Adam Beneschan
2006-12-07 22:35 ` Robert A Duff
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox