[squeak-dev] Why ReadWriteStream>>#contents?
Chris Cunningham
cunningham.cb at gmail.com
Tue May 1 20:20:06 UTC 2018
I suspect that is because ReadWriteStream is built to work roughly like
FileStreams- except over other arbitrary collections. Basically, let's you
read at arbitrary spots, go back, overwrite those spots, and then continue
on. As such, I would think #contents is exactly the right behavior. Take
this example:
|stream| stream := ReadWriteStream on: 'Chirs'.
stream next; contents. "---< 'Chris' - the contents of the underlying
collection, not some adhoc part."
What you are probably looking for is #resetToStart (which if you used in
your example would not have surprised you - although the name surprised me).
-cbc
On Tue, May 1, 2018 at 1:00 PM, Chris Muller <ma.chris.m at gmail.com> wrote:
> Does anyone know why ReadWriteStream overrides #contents from WriteStream?
>
> WriteStream behaves as I would expect
>
> |stream| stream := WriteStream on: String new.
> stream nextPutAll: 'chris'; reset; nextPutAll: 'C'; contents "--->
> 'C' as expected"
>
> but ReadWriteStream doesn't...
>
> |stream| stream := ReadWriteStream on: String new.
> stream nextPutAll: 'chris'; reset; nextPutAll: 'C'; contents "--->
> 'Chris' unexpected!"
>
> I want to reuse a ReadWriteStream, so I want #contents to honor the end
> position. What's going on here?
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20180501/63d630d6/attachment.html>
More information about the Squeak-dev
mailing list
|