[BUG]Stream class>on:from:to: & reset

Tim Rowledge rowledge at interval.com
Thu Sep 2 21:14:15 UTC 1999


On Thu 02 Sep, Andres Valloud wrote:

>  This problem is connected with another problem I ran into, and I've
>  delayed the solution because it was not a priority. When you compress
>  files, it's very beneficial to compress them together as if they were a
>  single file. This is called solid compression, and is the modern
>  equivalent of the a bit more grotesque TAR + COMPRESS Unix trick.
Sounds interesting stuff, but I'm not sure I see the connection to my
problem. Maybe I need another dose of caffeine? Wouldn't be the first time.

Anyway, I broke down and just tried out what happens if I add another
instvar to PositionableStream; nothing terrible at all. So at least the
release image is adequately clean for this to work. Adding 'startPosition'
and making sure that #reset uses it seems to work quite well, but whilst
looking around for candidates to change I've spotted a couple of methods
that concern me.

1) WriteStream and ReadStream both implement #on:from:to: and the two are
identical. PositionableStream also implements it, but does so by making a
partial copy of the collection. I don't feel very good about this, since
that means that the stream is (surprisingly, I think) disconnected from the
contents of the original collection if it should be alterd concurrently.
Added to this, the method is most unlikely to be run, since there are only
the two subclasses, ReadStream and WriteStream.

2) WriteStream implements #with:from:to: in a similar manner, by a partial
copy of the collection. This makes it quite different to WriteStream
class>with:, which does not do a copy.  It is however wrapped up in the way
that WriteStream work with already-populated collections, something I've
never really liked much. The problem part is that using a WriteStream
with: a collection and putting things with it will add to the original
collection, whereas using with:from:to: will add to the _partial copy_ and
requires you to send #contents to the stream to get back the now disjoint
collection. Ugleeeee. Oh, and nobody sends it anyway!

It seems to me that we can quite easily fix the original bug. I suspect
that it would be smart to remove PositionableStream class>on:from:to: and
WriteStream class>with:from:to: but I won't bother for now.

A tiny changeset is enclosed which illustrates the above 'fixes'. An
alternative would be simply to drop the pretense of handling #on:from:to:
cleanly.

tim


-- 
Fractured Idiom:- POSH MORTEM - Death styles of the rich and famous
Tim Rowledge:  rowledge at interval.com (w)  +1 (650) 842-6110 (w)
  tim at sumeru.stanford.edu (h)  <http://sumeru.stanford.edu/tim>

Content-Type: APPLICATION/Octet-stream; NAME="Stream-tpr.cs"

Attachment converted: Anon:Stream-tpr.cs (????/----) (00012EB6)





More information about the Squeak-dev mailing list