Streaming on all collections

Klaus D. Witzel klaus.witzel at cobss.com
Sun Feb 11 20:30:24 UTC 2007


Hi Damien,

on Sun, 11 Feb 2007 21:11:22 +0100, you wrote:
> Jon Hylands a écrit :
>> On Sun, 11 Feb 2007 18:00:10 +0100, Damien Cassou
>> <damien.cassou at laposte.net> wrote:
>>
>>> why isn't it possible to stream over OrderedCollections ?
>>  You can only add elements to an OrderedCollection by using #add: (or  
>> one of
>> its variants). WriteStream assumes that if you send #new: to the class  
>> of
>> the collection it is streaming over, you can then say #at: index put:
>> value, where index <= the collections size.
>
> Sorry, I was not clear enough. I'm not talking about implementation  
> details, but about semantic of streams. I don't understand why  
> WriteStreams would not deal with all kind of sequenceable collections.

You are right, insofar as the class comments of Stream,  
PositionableStream, ReadStream and WriteStream talk about a *sequence* (of  
stream operations, IMO).

But only (sub-)instances of ArrayedCollection provide a *fixed* range of  
integers as external keys.

In contrast to that, OrderedCollection has also integers as externals key,  
but not a fixed range of them: the range *varies* with the size of the  
instance.

A simulation of ArrayedCollection can be

  (1 to: 6) asOrderedCollection writeStream nextPutAll: 'string'; contents

/Klaus

>





More information about the Squeak-dev mailing list