#455 Add isReady method to stream class

None
open
nobody
Classes (154)
5
2012-08-22
2012-06-08
No

One question that always generates heated debate is how a "loop until stream eof" should be written. Usually this involves using lines() or signal on notready. lines() can't always be reliable with persistent streams and signal/call on NOTREADY can be awkward to use. It would be nice if there was a method that allows one to simply request whether the stream has hit a state where a read will fail. Something like this:

do while stream~isready
x = stream~linein
...
end

I'm undecided if a separate eof method is a good idea or not, but would not object to one.

Discussion

  • Bruce

    Bruce - 2012-06-08

    Can you refresh my memory on why "lines() can't always be reliable with persistent streams..."

    This would seems like the most obvious answer.

     
  • David Ashley

    David Ashley - 2012-06-08

    While I like this idea a lot, I think the implementation may not be as clean as a single isReady() method. One would also need to know whether or not the stream is persistent. On a persistent stream isReay() would be sufficient to know that you hit EOF. But on a stream that is not peresistent it would just mean that there is no data currently available, but does not mean that no data will be available later as these kind of streams do not have the ability to indicate an EOF condition.

    Maybe it would be sufficient to always show that data will be available on non-persistent streams (if we can find a way to identify them when we open them).

     
  • U. Zinngrebe

    U. Zinngrebe - 2012-06-08

    As user I expect that isReady() and NOTREADY have opposite meaning.

    I would find it confusing if a transient stream could be in a state where isReady() is false without the NOTREADY condition being raised.

     
  • Aviatrexx

    Aviatrexx - 2012-06-08

    I like this suggestion and submit that the proposed name and functionality is appropriate.. While the term NOTREADY reflects an error or terminal condition, isReady is a positive state.

    One advantage of isReady is that it could be used as a component of a compound condition, something not possible with the NOTREADY signal condition.

    Also, the setting of isReady can reflect the satisfactory state of multiple conditions, ensuring that data is available regardless the source.

     


Anonymous

Cancel  Add attachments





Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks