comp.lang.ada
 help / color / mirror / Atom feed
From: "Adam Beneschan" <adam@irvine.com>
Subject: Re: Get_Line problem (GNAT bug?)
Date: 6 Dec 2006 17:09:42 -0800
Date: 2006-12-06T17:09:42-08:00	[thread overview]
Message-ID: <1165453781.897598.296940@16g2000cwy.googlegroups.com> (raw)
In-Reply-To: 0SIdh.25629$E02.10458@newsb.telia.net

Björn Persson wrote:
> Adam Beneschan wrote:
> > After the
> > first Get_Line has consumed the characters M a c i e k <CR>, then, when
> > End_Of_Line looks ahead and sees that the next character is <CR>, it
> > should be able to return False immediately without needing to look
> > ahead to see whether <CR> is immediately followed by EOF.  And I don't
> > see why this wouldn't apply to an interactive file as well.
>
> I agree that that's how it should be, but it's not how End_Of_Line is
> defined: "Returns True if a file terminator is next, or if the combination
> of a line, a page, and a file terminator is next; otherwise returns False."

I meant to type End_Of_File.  But  End_Of_File is defined the same way:
it returns True if the combination of a line, a page, and a file
terminator is next.  (A.10.5(25))

However, I still don't think it should return True here.  The concepts
of line, page, and file terminator are logical concepts whose actual
representation is defined by the implementation (A.10(7-8)); it's not
correct to simply assume that <CR> (or <LF> or <CR><LF>) is equivalent
to a line terminator in all cases.  A.10(7) says that the end of a file
is marked by the combination of a line terminator, a page terminator,
and a file terminator.  I would hope that in the above case, the
logical end-of-file is considered to be a line terminator followed by a
page terminator followed by a file terminator; the line terminator and
page terminator here would be implicit, and would not be represented by
any actual bits in the disk file, but would be logically considered to
be present.  Thus, after Get_Line reads the first string, "Maciek", the
next things would be a line terminator (represented by the second <CR>)
followed by *another*  line terminator (implicit, not represented by
anything in the disk file) followed by a page terminator (also
implicit) followed by a file terminator (also implicit); thus,
End_Of_File would return false.

This is all implementation-dependent.  However, I'd consider that if an
implementation would return two strings for Get_Line ("Maciek" and "")
and raise End_Error only the third time Get_Line is called, but would
return True for End_Of_File after just the *first* Get_Line, then the
implementation would be in error since it isn't consistent.  You may be
able to interpret the RM in a way that would make this permissible, but
the unwritten rule is that implementations are supposed to act
sensibly, and this would not make sense.  (By the way, the behavior
that I believe makes no sense is also how GNAT is acting when reading
from a file opened with Open, rather than standard input.)

Somebody please correct me if I'm wrong.  If I'm wrong, though, and the
RM requires the behavior I'm seeing, then the RM doesn't seem to make
sense.

                            -- Adam




  reply	other threads:[~2006-12-07  1:09 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 [this message]
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
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