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,8d5bda3619cce0f8 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns13feed!worldnet.att.net!attbi_s22.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: C getchar() functionality in Ada References: <4999ce31$0$90266$14726298@news.sunsite.dk> <%5lml.519385$TT4.153916@attbi_s22> <499a6607$0$90276$14726298@news.sunsite.dk> In-Reply-To: <499a6607$0$90276$14726298@news.sunsite.dk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 173.16.158.68 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s22 1234903694 173.16.158.68 (Tue, 17 Feb 2009 20:48:14 GMT) NNTP-Posting-Date: Tue, 17 Feb 2009 20:48:14 GMT Organization: AT&T ASP.att.net Date: Tue, 17 Feb 2009 20:48:14 GMT Xref: g2news2.google.com comp.lang.ada:4653 Date: 2009-02-17T20:48:14+00:00 List-Id: Thomas Locke wrote: > > I will try this when my Ada skills have improved a bit. For now I will > focus on learning how to best use Text_IO. If you're interested in learning about Ada.Text_IO, that's fine. Your C example works equally well on text or other files; to mimic that in Ada you can't use Text_IO. If you limit your input to text, you can duplicate the functionality using Text_IO; the solution is similar to Rosen's, but with an infinite loop rather than the End_Of_File test, and with an exception handler for End_Error to exit the loop gracefully. (Some people object to such a use of exceptions, but it's the only way to get Text_IO to correctly process a file that ends with a blank line. Ada.Text_IO.End_Of_File is broken.) To learn about Ada, you shouldn't try to translate C programs. Rather, you should state the requirements and figure out how to implement them in Ada. It was not clear from your C program whether you wanted to know how to implement a program to copy any kind of file, and were simply mistaken in using Text_IO, or a program limited to text files, and the C simply couldn't express that limitation. -- Jeff Carter "This trial is a travesty. It's a travesty of a mockery of a sham of a mockery of a travesty of two mockeries of a sham. ... Do you realize there's not a single homosexual on that jury?" Bananas 27