|
![](/i/fill.gif) |
Warp wrote:
> Since reaching EOF is completely valid, how is the compiler supposed to
> make sure that you write a conditional which takes it into account?
Some languages can do this, actually, just like some can look at an enum
and tell you when your switch statement doesn't cover all possibilities.
:-) It's pretty cool, but certainly not something you could do in a
language based on the machine level, like C is.
> In fact, returning EOF multiple times is not an error either
> (it can be perfectly possible for different parts of the program to read
> the same file, and all of them get an EOF when there's nothing more to
> read, and all of them still work properly).
Actually, from the keyboard, you can read data, get an eof, read more
data, and get another eof, just by typing ctrl-D twice.
> So how is the compiler supposed to make sure that you do the "correct"
> thing when EOF is returned? What *is* the "correct" thing to do?
Not compile a program that tries to read past EOF?
--
Darren New / San Diego, CA, USA (PST)
Post a reply to this message
|
![](/i/fill.gif) |