JarrettBillingsley
Joined: 20 Jun 2006 Posts: 457 Location: Pennsylvania!
|
Posted: Thu Jan 08, 2009 9:40 am Post subject: More IO library changes.. |
|
|
I'm still unhappy!
I'm thinking about what kinds of streams there really are. Currently a Stream has an InputStream and an OutputStream. This is icky, because if you get the input or output, and mess with it, you mess up data coherence on the source stream. Since Streams support all methods of InputStreams and OutputStreams anyway, why bother giving you access to the input and output? MiniD is duck-typed..
There seem to be a few "basic" types of streams.
- Sources - Read-only
- Sinks - Write-only
- Bidirectional (Bidi) - Read-write
Most of the time, streams fall into the first two categories. Usually you open files for just reading or just writing, or those streams correspond to pipes or sockets or something (which sometimes are two-way, but the two ways go to and come from two different places, so they could be considered two streams, a source and a sink).
Another aspect of streams is seekability. About the only seekable streams that I can think of are files and memory buffers. Nonseekable input streams can also be skipped forward without any special support. Buffering changes some things - you can seek maybe a little forward or back on a buffered stream, as long as the seek is within the buffer. But that's kind of a moot point. It also seems that all truly bidirectional streams - where the input and output come from and go to the same place - are seekable.
The stream lib will remain mostly the same on the outside. InputStream will probably be renamed InStream or SourceStream; OutputStream to OutStream or SinkStream; and Stream to InoutStream or BidiStream. Seeking methods will be added to InputStream and OutputStream, as well as close methods. The .input() and .output() methods will be removed from Stream.
The io lib will only change with regards to File and FileMode. FileMode will probably go away, and File will be replaced with something like "inFile, outFile, inOutFile", which return input, output, and bidi streams, respectively.
Get ready! |
|