From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,68cd50941308f5a9,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!j72g2000cwa.googlegroups.com!not-for-mail From: "Adam Beneschan" Newsgroups: comp.lang.ada Subject: End_Of_File but not really Date: 7 Dec 2006 10:00:26 -0800 Organization: http://groups.google.com Message-ID: <1165514423.562024.70510@j72g2000cwa.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1165514433 12744 127.0.0.1 (7 Dec 2006 18:00:33 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 7 Dec 2006 18:00:33 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: j72g2000cwa.googlegroups.com; posting-host=66.126.103.122; posting-account=cw1zeQwAAABOY2vF_g6V_9cdsyY_wV9w Xref: g2news2.google.com comp.lang.ada:7854 Date: 2006-12-07T10:00:26-08:00 List-Id: This is based on some of the things I've been saying on Maciej's thread about the Get_Line problem. I ran this test using GNAT. Note that my input file is a disk file, to avoid the additional issues that arise with interactive files. with Ada.Text_IO; use Ada.Text_IO; procedure IOTest is Line : String(1..100); Last : Integer; F : File_Type; EOF : Boolean; begin Open(F, In_File, "f1"); loop begin EOF := End_Of_File (F); Get_Line (F, Line, Last); if EOF then Put_Line ("End_Of_File returned TRUE but Get_Line did not raise an exception"); exit; end if; exception when End_Error => Put_Line ("End_Error raised"); exit; end; end loop; end IOTest; If I try this on Linux, on a file whose bytes are abc, then the message "End_Of_File returned TRUE but Get_Line did not raise an exception". This strikes me as bizarre---if End_Of_File returns True, then a subsequent read operation should raise an End_Error, but that isn't what's happening. One of these must be true: (1) The RM does not allow this behavior, and GNAT is broken. (2) This behavior is what the RM requires. To me, this means the RM is broken---it just doesn't make sense to me that End_Of_File would return True if there is more information in the file to get with Get_Line (even if the information is "the presence of a blank line"). But perhaps it's my own understanding that is broken; perhaps my understanding of what End_Of_File is supposed to do is wrong, even though I think it's what a reasonable person would expect a function called "End_Of_File" to do. (3) The behavior is implementation-defined according to the RM (because the nature of terminators is implementation-defined), and it's possible to have an implementation that never displays this message and an implementation that is capable of displaying message both conforming to the RM. In this case, though, I'd say (3a) the RM is a little bit broken, because even though the representation of terminators is implementation-defined, it would seem that the definitions of End_Of_File and End_Error ought to conform to each other, so that the above message could never appear, and (3b) GNAT is broken, because even though the RM allows it to implement Text_IO in a way that causes the above message to appear, it shouldn't because it doesn't make sense. So which is it? Thoughts? Comments? -- Adam