[plt-scheme] no #!eof
Only by access to the next lower level (device being the lowest, then
blocks, rbts, fats etc and at the top the stream itself).But the nice thing
of a stream is that it abstracts all lower levels away. Therefore it should
be imposible to continue writing after the stream has been declared to be
ended, Therefore it should not allow *writing* an eof mark. At the stream
level eof must not be a datum. Hitting the end of a stream is a kind of
exception, although not necessarily an erroneous one. Oh yes, the eof-object
is a datum, but fortunately writing this datum does not write an eof mark!
How do we know that we hit the end of a proper list? Because nil is not a
pair and because Scheme makes it impossible to replace nil by a pair (which
is quite different from replacing the last cdr of a mutable list, for this
acts on a pair, not on nil) Imagine a Scheme that allows taking the cdr of
nil. The whole language would collapse into one big contradiction. When we
take the cdr of nil, we don't interpret the resulting exception as a datum,
do we? Allowing to read on after hitting the end of a stream is like making
cdr return the exception as a value rather than passing the exception to the
exception handler.
You may also compare this to reading a damaged magnetic tape (in the old
days). In order to do this you have to read the tape at a lower level,
closer to the hardware. You'll have to interpret the contents of individual
blocks, (both label and data blocks) yourself and in some cases you can only
know that there realy is no more to read after the system signals that the
end of the physical tape has come loose from the reel (angry operator at the
main frame console, for he/she has to come out of his/her cosy and luxery
chair and it may require some effort to put the tape back into the reel) And
even if the tape come loose from the reel, you cannot be sure that you have
read it all for the tape may be a volume of a multi volume tape, which you
cannot know for sure in case volume information has been damaged) On a
random access device things are even far more complicated.
mho, Jos
----- Original Message -----
From: "Joe Marshall" <jmarshall at alum.mit.edu>
To: "Abdulaziz Ghuloum" <aghuloum at cs.indiana.edu>
Cc: "Dave Herman" <dherman at ccs.neu.edu>; "PLT Scheme Mailing List"
<plt-scheme at list.cs.brown.edu>
Sent: Tuesday, April 15, 2008 9:46 PM
Subject: Re: [plt-scheme] no #!eof
> If you can put EOF markers in the middle of a stream, then how do you
> reliably detect if there is more to be read?
>
>
> --
> ~jrm
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme