Streaming on OrderedCollection

Travis Griggs tgriggs at keyww.com
Thu Sep 3 21:50:45 UTC 1998



Bob Arning wrote:

> Travis,
>
> A couple of thoughts -
>
> I seem to remember OrderedCollection>>at:put: in VSE assuming the client was a bit more knowledgeable and simply adjusting the contents (i.e. growing them) so that #at:put: would work.
>
> Do you really want a stream on an OrderedCollection?

Yes. I consider OrderedCollection the workhorse of Smalltalk collections. Interesting collection type things are usually done with them. The fact that VW, ST/X, and now as you point out, VSE, supports WriteStream'ing on an OC, would seem to validate this.

> There are probably other similar problems lurking here (OrderedCollection>>size, e.g.). In addition you are incurring an extra level of overhead - especially since some methods in Stream classes are actually primitives that work for String and Array collections. Perhaps you'll be happier all around using an Array instead.

No, I don't think so. If multiple other Smalltalks can do this, I can't imagine it's that hard. I've never had any sort of weird problems in ST/X or VW because WriteStream'ing worked on both OCs and Arrays. I haven't looked at the methods in the Squeak stream classes, but it sounds like I might be doing more of it. :) If as you say is true, that some of the methods include
primitives which are specialized for String/Array, then that's wrong. If such is the case, then a subclass of WriteStream called StringWriteStream, or ArrayWriteStream should be written, which overrideds a more generic implementation with the appropriate primitive.

> I also think Allen's recent suggestion on another subject a good one. When we are dealing with such fundamental areas, it would pay to see what the ANSI spec says and move in that direction unless we see a compelling reason to do otherwise.

Good idea. I looked at page 273 (section 5.9) where it shows that WriteStream is the union of  <collectionStream>, <puttableStream>, and <sequencedStream>. The description of <collectionStream> says:

    "An object conforming to <collectionStream> has a <sequencedReadableCollection> as its stream backing store." (5.9.3, pg 280)

Now, if I flip back to page 156 (section 5.7), it shows that OrderedCollection is among the union of many things, <sequencedReadableCollection>.

I'm not sure how interpret all of this legalise type reading, but it looks like according to the ANSI spec that one should be able to WriteStream on an OrderedCollection. Maybe Allen can help out with the interpretation?

BTW Bob, thanks MUCHO for the VW importing stuff. It made my life a ton easier. OTOH, it lead to opening up the above can of worms. :)

--
Travis Griggs
Key Technology
tgriggs at keyww.com
Smalltalk - 100% Pure Objects, Always had 'em, Always will!





More information about the Squeak-dev mailing list