eof

greg greg at cosc.canterbury.ac.nz
Sat Nov 24 00:51:35 EST 2007


Dennis Lee Bieber wrote:
> 	Pascal I/O worked with a "one element preread", where what we'd
> consider a read operation was performed by the open operation -- which
> made console I/O a royal pain

Yep. Later implementations reduced the pain somewhat by
using a "lazy" scheme which deferred the read until
you tried to do something with the buffer. But they
couldn't completely hide the fact that testing for eof
requires a lookahead.

> Original Pascal uses
> 
> f = open(somefile)
> do something with f^
> read(f)

Actually, I think it was get(f) to read the next record
into the buffer. Read(f, x) was a higher-level procedure
equivalent to something like

   x = f^;
   get(f)

Plus for text files read() and write() did various other
fancy things.

--
Greg



More information about the Python-list mailing list