What is best way to implement "tail"?

L

Lew Pitcher

On Sep 20, 10:01 am, (e-mail address removed) (Richard Tobin) wrote:
[snip]
Anyway, what is the point of the WaitFiveSecs function? If you're
going to busy-wait, why not just keep calling getchar()?

Well, I wasn't going to busy-wait, but I couldn't find a sleep()
function in C90. Of course, you are right; repeated calling of
getchar() would have been better than either sleep() or a busy-wait
loop. (FWIW, I hoped that the clock() call might actually perform some
sort of system-dependant wait itself, thus reducing the overhead of
the busy-wait loop.)
 
A

Army1987

Chris Torek said:
(Implementations are allowed, but not required, to have this sort
of "sticky EOF" behavior.

C99 says, under fgetc():

If the end-of-file indicator [...] is set, or if the stream is at
end-of-file, the end-of-file indicator [...] is set and the fgetc
function returns EOF.

C90 is less clear: it says:

If the stream is at end-of-file, the end-of-file indicator [...] is
set and the fgetc function returns EOF.

So it seems to have been changed to clarify that sticky behaviour is
required.
"Is set" can be interpreted as the passive of "set" rather than
as "is" and an adjective. If the sentence is taken to mean "If the
fgets() sets the end-of-file indicator, it returns EOF", the
sticky behaviour is not required.
 
R

Richard Tobin

C99 says, under fgetc():

If the end-of-file indicator [...] is set, or if the stream is at
end-of-file, the end-of-file indicator [...] is set and the fgetc
function returns EOF.
[/QUOTE]
"Is set" can be interpreted as the passive of "set" rather than
as "is" and an adjective. If the sentence is taken to mean "If the
fgets() sets the end-of-file indicator, it returns EOF", the
sticky behaviour is not required.

That makes no sense, because it would mean "if fgetc() set the
end-of-file indicator ... fgetc() sets the end-of-file indicator and
returns EOF".

-- Richard
 
A

Army1987

That makes no sense, because it would mean "if fgetc() set the
end-of-file indicator ... fgetc() sets the end-of-file indicator and
returns EOF".
But neither would your interpretation, if it is already set why
set it again? But wait... "If the end-of-file indicator for the
stream is set,[...] the end-of-file indicator for the stream is
set[...]. They can't be the same proposition, can they? OMG...
(The answer is in the paragraph above. You are correct.)
 
R

Richard Tobin

Army1987 said:
But neither would your interpretation, if it is already set why
set it again?

You might think that, but then that's just the question - is it sticky?
But wait... "If the end-of-file indicator for the
stream is set,[...] the end-of-file indicator for the stream is
set[...]. They can't be the same proposition, can they?

Exactly. The sentence only makes sense if the two instances of "the
end-of-file indicator for the stream is set" are interpreted
differently. Writing standards unambiguously is hard.

-- Richard
 
R

Richard Tobin

Do you mean that writing unambiguous standards is hard, or do you mean
that writing standards is unambiguously hard?

Yes, that's exactly what I mean.

-- Richard
 
K

Keith Thompson

Writing standards unambiguously is hard.

Do you mean that writing unambiguous standards is hard, or do you mean
that writing standards is unambiguously hard?

:cool:}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top