WriteStream>>contents

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

WriteStream>>contents

Damien Cassou-3
Do you think that the following behavior is desired?

stream := WriteStream with: 'something'.
stream contents.                     => 'something'
stream position: 2.
stream contents.                     => 'so'

We get the same result on Squeak and VisualWorks.

Based on ANSI, #contents must return 'something' on both cases.

--
Damien Cassou

Reply | Threaded
Open this post in threaded view
|

RE: WriteStream>>contents

Ron Teitelbaum
Hi Damien,

I can understand it both ways.  

I agree that sending contents after setting the position is a bit odd.  It
is quite easy to get the results in other ways.  It would make sense to get
entire contents if for example we are editing a stream.

On the other hand the current contents of the write stream itself do only
include what is before the current position, since everything else will be
written over when you add to the stream without changing the position.  

Having position linked to contents allows for things like backspacing
without having to purge the write stream of data.

Both ways make sense, since this seems to be consistent with other
smalltalks you have to wonder if a change would cause problems in things
like ParagraphEditor.  I would say that we should leave it and provide a new
method called #fullContents or something like that to get the desired
results.  (and change the standard?).  What do other Smalltalks do?

Ron Teitelbaum


> From: Damien Cassou
>
> Do you think that the following behavior is desired?
>
> stream := WriteStream with: 'something'.
> stream contents.                     => 'something'
> stream position: 2.
> stream contents.                     => 'so'
>
> We get the same result on Squeak and VisualWorks.
>
> Based on ANSI, #contents must return 'something' on both cases.
>
> --
> Damien Cassou
>



Reply | Threaded
Open this post in threaded view
|

Re: WriteStream>>contents

Nicolas Cellier-3
In reply to this post by Damien Cassou-3
Beside, the ANSI behaviour you are looking for is in ReadWriteStream.
So maybe no use to change WriteStream.

stream := ReadWriteStream with: 'something'.
stream contents. "=> something"
stream position: 2.
stream contents. "=> something"
stream nextPut: $Z.
stream contents. "=> soZething"

Nicolas

Damien Cassou a écrit :

> Do you think that the following behavior is desired?
>
> stream := WriteStream with: 'something'.
> stream contents.                     => 'something'
> stream position: 2.
> stream contents.                     => 'so'
>
> We get the same result on Squeak and VisualWorks.
>
> Based on ANSI, #contents must return 'something' on both cases.
>