ReadWriteStream Issues

Frank Sergeant frank at canyon-medical.com
Mon May 5 23:16:14 UTC 2003


> <<I've been reading the "Squeak: A Quick Trip to
> ObjectLand" book and have come across some problems
> with getting the examples using ReadWriteStream to
> work (on page 174-175). I don't get the same results
> as the book states as one should expect.>>

Just a quick note or two in case it helps before someone posts the
definitive answer:

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.  Also, rather than just
executing your block of code in a workspace, highlight it, right click,
and choose 'debug' and then you can single step through the code and
easily examine the stream etc as you go.

There was the mention of the problem of writing to a ReadStream, but, of
course, you shouldn't write to a ReadStream.

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.

Also note #on: versus #with:.  Isn't one of these preferred and the
other obsolete?


-- Frank



More information about the Squeak-dev mailing list