FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

More IO library changes..

 
Post new topic   Reply to topic     Forum Index -> MiniD
View previous topic :: View next topic  
Author Message
JarrettBillingsley



Joined: 20 Jun 2006
Posts: 457
Location: Pennsylvania!

PostPosted: Thu Jan 08, 2009 9:40 am    Post subject: More IO library changes.. Reply with quote

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!
Back to top
View user's profile Send private message
csauls



Joined: 27 Mar 2004
Posts: 278

PostPosted: Fri Jan 09, 2009 2:50 pm    Post subject: Reply with quote

Makes sense to me. I vote for the Source/Sink/Bidi naming scheme. Makes one think a little more about how the stream is really used than In/Out.
_________________
Chris Nicholson-Sauls
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> MiniD All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group