Madhu
5/8/2015 4:10:00 AM
* "Pascal J. Bourguignon" <87oalverla.fsf@kuiper.lan.informatimago.com> :
Wrote on Fri, 08 May 2015 04:22:09 +0200:
|> | We must take into account foremost the first sentence: is a character
|> | immediately available from input-stream? For file-streams, this can be
|> | known non-destructively only if the stream is buffered, and if there is
|> | a character in the input buffer.
|>
|> No. For file streams the file size and file position are well known.
|
| No. For character file streams, the file length is not specified,
| therefore there can be no conforming usage of file-length on character
| file streams.
Are you disputing that the file has a certain length? This has nothing
to do with CL's FILE-LENGTH. Are you disputing there is a
file-position? This has nothing to do with CL's FILE-POSITION.
| file-length returns the length of stream, or nil if the length
| cannot be determined.
|
| For a binary file, the length is measured in units of the element
| type of the stream.
|
| Notice how nothing is said specifically for text files, so only the
| first paragraph applies. Nowhere is the length of stream defined.
You are purposely deviously confounding CL's user definitions of
FILE-LENGTH and FILE-POSITION with the underlying concepts of file
length and file position. The underlying concepts of file-length and
file-position unambiguously tell you whether or not you are at an
end-of-file situation, regardless of whether this is a character stream
or a binary stream or a bivalent hybrid stream or any extended stream.
<snip>
|> The stream implementation accounting keeps track of which position is
|> being read if the stream is buffered or if it unbuffered. The
|> end-of-file is entirely determinable.
|
| At one point in time, but one nanosecond later, it's wrong. That's the
| problem with concurent and multi-process multi-user systems.
It makes no difference. That race conditions exist unrelated. The
specification relates to the state at the point the call is made.
|> | Similarly for a buffered interactive stream (eg. a terminal in line
|> | mode).
|> |
|> | But for unbuffered streams (interactive, socket streams, etc), unless
|> | you just called UNREAD-CHAR, we cannot assume either result.
|>
|> implementation of UNREAD-CHAR can again use a single charcter
|> buffer. This is all very hokey while the spec is precise.
|
| The OP asked for BINARY streams!
The unread-char strawman was yours, not mine.
|> | The problem is that in general, end-of-file is not a state, it's an
|> | event, despite the language used in the above description.
|>
|> In the case of file-streams end-of-file is a state, which is reached
|> when the last character or byte has been read.
|
| No, as I explained in details, in unix, a file can be modified while it
| is being open and read, be it by other processes or by the same process!
| Therefore as soon as a syscall returns, any value it may give you about
| the state of the file system can and will be wrong!
|
| Learn your unix!
It does not matter, your hypothetical situations do not apply. The
problem is the same in the alternative you want to provide. Your file
will signal and END-OF-FILE and the next nanosecond you could have
written to it so it is no longer at the END OF the FILE
This does not make the END-OF-FILE signalling wrong at the time it was
signalled.
Do you see where your flawed reasoning leads? This is only going in
circles now. ---Madhu