On (20 Jul 97) Thomas Maeder wrote to Cameron Clark...
CC> MYifstream.get(char c) {
CC> ifstream::get(c);
CC> if (ifstream::gcount()==0) {
CC> "thow end of file exception"
CC> }
CC> }
TM> Don't do this! An input stream isn't supposed to throw an exception on
TM> end of file. There is no good reason for it, since eof isn't an
TM> exceptional situation.
That depends. Under these circumstances, I quite agree. OTOH, consider
if you have a database file with a header that tells the size of each
record, and the number of records the file contains. If the file is
shorter than than says, you DO have an exceptional condition.
FWIW, using exception handling to deal with the end of a file WAS
perfectly normal under PL/I. Then again, PL/I sort of gave exception
handling a bad name for quite a while - these two things may be related.
Later,
Jerry.
... The Universe is a figment of its own imagination.
--- PPoint 1.90
---------------
* Origin: Point Pointedly Pointless (1:128/166.5)
|