[squeak-dev] Bits of history: Stream >>contents

Ron Teitelbaum ron at usmedrec.com
Tue Jun 29 20:14:41 UTC 2021


Hi Ken,

I think the issue is that when you change the position of the stream you
are really telling it to limit the write stream to that position.  It's a
way to hit backspace and start over.

so if I say position is 2 then I get the first two elements only.

ws := WriteStream on: #[].
ws nextPut: 65.
ws nextPut: 80.
ws nextPut: 50.
ws contents printString. '#[65 80 50]'
"limit to position 2"
ws position: 2.
ws contents printString.  '#[65 80]'

"I can then write more from there."

ws nextPut: 51.
ws contents printString.  '#[65 80 51]'

All the best,

Ron Teitelbaum

On Tue, Jun 29, 2021 at 3:10 PM <ken.dickey at whidbey.com> wrote:

> Greetings,
>
> Perhaps some one out there can help me understand some history.
>
> ANSI Smalltalk 5.9.1.2 indicates that #contents "Returns a collection
> containing the complete contents of the stream."
>
> WriteStream>>contents does not do this.  ReadWriteStream>>contents does
> do this.
>
> Why the difference?
>
> vvv===vvv
> ws := WriteStream on: #[].
> ws nextPut: 65.
> ws nextPut: 80.
> ws contents printString. '#[65 80]'
> "Second result is expected to match 1st"
> ws position: 1.
> ws contents printString. '#[65]'
> ^^^===^^^
>
> I am puzzled.  Must be some reason for this lost in the sands of time..
>
> Thanks for any help uncovering the history and rationale here,
> -KenD
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20210629/9245b667/attachment.html>


More information about the Squeak-dev mailing list