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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,bc243f3bb85ffa4f X-Google-Attributes: gid103376,public From: eachus@spectre.mitre.org (Robert I. Eachus) Subject: Re: Exceptions: Are they GOTOs? Date: 1996/07/16 Message-ID: #1/1 X-Deja-AN: 169297676 references: <4s4gic$etl@news.pacifier.com> organization: The Mitre Corp., Bedford, MA. newsgroups: comp.lang.ada Date: 1996-07-16T00:00:00+00:00 List-Id: In article <4s8jjs$1gu@felix.seas.gwu.edu> mfeldman@seas.gwu.edu (Michael Feldman) writes: (Lots of good stuff including:) > If I _forget_ to write correct code to test for end-of-file, > and unexpectedly hit the end of the file, Ada.Text_IO.End_Error > _will_ be raised. If that happens, it is because my code has a > bug in it - I forgot the test (or wrote it incorrectly). However, I'd like to point out that always checking for end-of-file is also inappropriate. The rule I use is that an incorrectly structured file can cause End_Error, but reaching the end of the file "normally" should always be handled by checking for end-of-file. For example, suppose I am reading a table of city names and high and low temperatures for the day: while not Text_IO.End_of_File(foo) loop begin Get_Name_of_City Int_IO.Get(foo, High); Int_IO.Get(foo, Low); Skip_Line(foo); exception when Text_IO.End_Error => Deal_With_Incomplete_Record; exit; ... end; end loop; ... ... If I get to this handler it is because the file ended in an incomplete record. Now oyu may argue that I should read each line into a buffer, then process it. I will usually operate that way, but the point still remains: you will get End_Error if temperature data is missing, but correct files will never cause an exception. -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...