On 03/26/2012 02:12 PM, Tyro[17] wrote:
> I don't want to provide an explicit terminator, but instead
> rely on Ctrl-D/Ctrl-Z to do the job while being able to
> continue processing read request. As explained by Andrei,
> this is not possible. But in my mind if the stdin stream
> can be opened once, it can be opened again. What is the
> negative effect of testing if it is closed and reopening it
> on entering readf? Especially since there is a unique
> implementation of readf to deal with input from stdin.
>
> What is wrong with implementing reopen() in File for
> specific use with stdin and then implementing readf
> like this:
>
> uint readf(A...)(in char[] format, A args)
> {
> if(stdin.eof) stdin.reopen();
> return stdin.readf(format, args);
> }
>
> AndrewThat doesn't fit the way standard input and output streams work. These streams are bound to the application from the environment that has started them. The program itself does not have a way of manipulating how these streams are ended or connected.
Imagine that your program's stdin if piped from the output of another process:
other | yoursOnce 'other' finishes with its output, that's the end of the input of 'yours'. 'yours' cannot communicate to the environment that it would like to continue reading more.
What you are asking for could be achieved only if both the environment and the program agreed that this would be the case.
Maybe I am missing something but that has been standard on many environments.
Ali
