ReadWriteStream issues

Anthony Adachi adachipro at yahoo.com
Sun May 4 18:49:49 UTC 2003


Hello

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.

For instance, the following is a series of message
sends from the book and what it says are the expected
returned values:

s := ReadWriteStream on: #(1 2).
s next. "expected returned value should be 1"
s next. "...should be 1"
s atEnd. "...should be true"
s reset.
s next. "...should be 1"
s position. "...should be 0"

However, this is what I actually got:

s := ReadWriteStream on: #(1 2).
s next. ".result is nil while expected result should
be 1 according to the book"
s atEnd. "results in true"
s position. "Answers 0"
s reset.
s next. "result is nil should be 1 according to the
book"
s position. "Again, answers 0 while it should be 1"
s atEnd. "true again despite reset message send"
s contents. "#()"

I stepped through the on: message sent to
ReadWriteStream and noticed that the read limit is set
to 0.

I tried sending the with: message to see what
happened.

s := ReadWriteStream with: #(1 2).
s next. "result returned is nil"
s position. "2"
s atEnd. "true"

Again, the next message returned nil instead of 1.
Although, this time the position messaged returned 2.

The results are closer to what the book expects if a
reset message is sent and the with: creation method is
used instead of on:.

s := ReadWriteStream with: #(1 2).
s reset.
s next. "1 as expected"
s next. "2 likewise, as expected"
s atEnd. "true"

Has Squeak's ReadWriteStream class's interface changed
since this book has been published or something other
problem? I'm using Squeak 3.5 on Mac OS 9.1

Thanks,

Anthony

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



More information about the Squeak-dev mailing list