Stream Question

Dan Ingalls Dan at SqueakLand.org
Wed Sep 19 15:51:47 UTC 2001


>Ok, I see that I have to keep track of positions which I had at first assumed was being handled by the stream itself.

Hi, Ken -

This should all be cleaned up some day.  It wouldn't be that hard, and I think there are even some cleanups available for the asking.

Anyhow, to answer your questions...

>How does one normally handle the case when writing to a stream approaches the end of allotted space, for example writing to a Transcript?

Well, you can look at Transcript, but it's sort of mixed in with its viewer.  [I'm assuming you know that essentially all streaming collections in Squeak will grow by themselves as long as there is memory available.]

The cleanest approach I have seen is that if the nextPut: method fails due to hitting the end of buffer, it sends self pastEndPut:.  This can then be implemented by various subclasses to drop the oldest input, or stream it onto a file, or raise an error.

>I suppose if near the end you could reset but that may not have the desirable results. Is there some sort of first in first out stream available somewhere?

OrderedCollection has a complete set of addFirst, addLast, removeFirst, removeLast, and reasonable space management if you use it for a FIFO queue.  If you want it to be compatible with the other streams, you'll have to dress it up with the normal stream protocol (next, nextPut, atEnd, etc).

SharedQueue has an additional overhead for synchronization of independent processes, but it has the proper protocol already.

You can see why I mean by "should all be cleaned up some day" ;-).

Hope this helps

	- Dan
-- 




More information about the Squeak-dev mailing list