You haven't set the writeLimit by just copying PositionableStream though, have you? Perhaps: ReadWriteStream >> on: aCollection super on: aCollection. readLimit := aCollection size. would be a better idea? Intervals can't be stored into by the way, so using a RWStream on one doesn't make much sense ;) here's a more accurate example for RWStream: rws := ReadWriteStream on: (1 to: 20) asArray. [rws atEnd] whileFalse: [rws peek odd ifFalse: [rws nextPut: 0] ifTrue: [rws next]] And the collection will contain #(1 0 3 0 5 0 7 0 9 0 11 0 13 0 15 0 17 0 19 0), as expected. Cheers, Henry On Jun 30, 2009, at 3:00 46PM, Alexandre Bergel wrote:
Put the readLimit at 0 make sense for a WriteStream ( with witch your not supposed to read ) but when you create a ReadWriteStream on a collection you would be able to read what is already in the collection, no? I wonder why #on: has not been overriden in the instance side of ReadWriteStream ? Maybe it's not a good idea to create a ReadWriteStream with a collection that already includes elements ?
It looks like on: must be overridden in ReadWriteStream. With ReadStream I have: (ReadStream on: (1 to: 20)) next => 1 (ReadStream on: (1 to: 20)) next; next => 2
However, with ReadWriteStream, nil is returned, for the very problem you mentioned: (ReadWriteStream on: (1 to: 20)) next => nil
If I cut and paste PositionnableStream>>on: in ReadWriteStream, then I have the behavior I expected: (ReadWriteStream on: (1 to: 20)) next => 1 (ReadWriteStream on: (1 to: 20)) next; next => 2
Cheers, Alexandre
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project