comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <rieachus@earthlink.net>
Subject: Re: End of File for streams
Date: 2000/04/17
Date: 2000-04-17T00:00:00+00:00	[thread overview]
Message-ID: <38FBA3B4.BBE9078E@earthlink.net> (raw)
In-Reply-To: 8dg55l$us3$1@trog.dera.gov.uk

Kevin Rigotti wrote:
> 
> OK, its nice to have some external confirmation occasionally. I don't get to
> see much code written by other people here ...
> 
> In my own defence (but thanks Brian)
> 1) as an impressionable undergrad I was brought up on a diet of functional
> programming so using exceptions for control flow seems decadent :-)
> 
> 2) I don't like using exceptions for non-exceptional behavior. Just a
> personal foible.

    The "normal" Ada design for reading entries from a file uses the
End_Error exception as an exception, while correct data results in an
exit due to End_Of_File:

   while not End_Of_File(Input_File) loop
     begin
       Get_Item_1;
       Get_Item_2;
       Get_Item_3;
     exception
       when End_Error | Data_Error | Device_Error =>
          Correct_Partial_Entry;
       when others =>
          ...
     end;
   end loop;

   Reading a character at a time is a degenerate case, and you can do
that either way.  I guess it is not considered a major issue in Ada,
since the expected behavior is to read data in larger chunks.  (Stream
files are a different situation, and there the expected behavior when
you run out of data is to wait for more. ;-)




  reply	other threads:[~2000-04-17  0:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-04-17  0:00 End of File for streams Kevin Rigotti
2000-04-17  0:00 ` Gautier
2000-04-17  0:00 ` Robert Dewar
2000-04-17  0:00   ` Brian Rogoff
2000-04-17  0:00 ` Gautier
2000-04-18  0:00   ` Kevin Rigotti
2000-04-17  0:00     ` Robert I. Eachus [this message]
2000-04-18  0:00     ` Robert Dewar
2000-04-18  0:00     ` Jean-Pierre Rosen
2000-04-18  0:00       ` Brian Rogoff
2000-04-18  0:00         ` Jean-Pierre Rosen
2000-04-19  0:00           ` Brian Rogoff
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox