ReadWriteStream Issues

Anthony Adachi adachipro at yahoo.com
Mon May 5 23:06:35 UTC 2003


Frank Sergeant  wrote:

>  I don't think you need to modify any of Squeak. I
think you just need
>  to add the missing #reset after creating the
ReadWriteStream and before
>  trying to read from it. Otherwise, you are trying
to ready past the end
>  and, naturally, there is nothing there. 

Sending a reset message to the ReadWriteStream
instance does not resolve the unexpected behaviour.

s := ReadWriteStream on: #(1 2).
s reset.
s next. "returns nil"
s atEnd. "returns true"
s position.  "returns 0"
s contents. "returns #()"

>  Also, you have been opening the ReadStream or
ReadWriteStream on a
>  *literal*. I think this is ok for the ReadStream
but I don't think it
>  is a good idea in general for a stream that can be
written to. Instead
>  of
>  
>  s := ReadWriteStream on: #(a b c).
>  
>  I would would be more comfortable with opening it
on a copy, e.g.
>  
>  s := ReadWriteStream on: #(a b c) copy.

Making a copy of the literal does not alter the
results either.

s := ReadWriteStream on: #(a b c) copy.
s reset. "a ReadWriteStream"
s atEnd. " true"
s position." 0"
s next. " nil"
s contents." #()"

However, as I mentioned in my first post, if one sends
the message "with:" instead of "on:" immediatly
followed by "reset" then one can get the results the
book expects.

Whether this is the expected behaviour by the
ReadWriteStream class' authors is the question?

Anthony

__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com



More information about the Squeak-dev mailing list