[squeak-dev] Bits of history: Stream >>contents
ron at usmedrec.com
Tue Jun 29 20:14:41 UTC 2021
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,
On Tue, Jun 29, 2021 at 3:10 PM <ken.dickey at whidbey.com> wrote:
> Perhaps some one out there can help me understand some history.
> ANSI Smalltalk 126.96.36.199 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?
> 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. '#'
> 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,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev