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,66144fcff23c0cc6 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.66.82.103 with SMTP id h7mr9262918pay.11.1357364046090; Fri, 04 Jan 2013 21:34:06 -0800 (PST) MIME-Version: 1.0 Path: 6ni82910pbd.1!nntp.google.com!news.glorb.com!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.x-privat.org!news.jacob-sparre.dk!munin.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Trouble with loop in Ada Date: Fri, 4 Jan 2013 23:33:56 -0600 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1357364044 17656 69.95.181.76 (5 Jan 2013 05:34:04 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Sat, 5 Jan 2013 05:34:04 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Date: 2013-01-04T23:33:56-06:00 List-Id: "Derek Wyss" wrote in message news:kc7hgn$gse$1@speranza.aioe.org... ... > Paul, thanks for your helpful hints as well. My next steps for improving > my toy will be to explore > > End_Of_File vs. End_Of_File(Standard_Input) --I like the 2nd one, seems > more clear > > Get vs. Get_Immediate --That should be easy but for me it's worth some > consideration > > Then I'll look at using exceptions in my code like you did. I'd suggest that you go as quickly as possible to using exceptions. It's almost never fool-proof to pre-test for I/O, because something else running on the computer could change the I/O stream between the test and the read (this is known as a "race condition"). By handling the exceptions, you avoid any problems like that, and while it doesn't really make any difference in a toy example, it's a good practice to get into right away. (Additionally, End_of_File tends to bog down performance for Text_IO; again, that doesn't matter in a toy program, but it's another reason to avoid it.) This is even more true when Opening/Creating files. Just do it and handle the exception -- *never* try to pretest for existence - the result means nothing as the file could be created or deleted after the test and before you actually do the Open. And then you *still* have to handle the exceptions (unless the program is a throw-away toy, and even then, good habits are recommended), so why bother with the extra test? Randy.