ReadWriteStream Issues

Bert Mayo bertmayo at earthlink.net
Mon May 5 20:41:10 UTC 2003


On May 4 Anthony Adachi wrote:

<<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.>>

Hi,

Small World!!  I've been reading the same book and ran into the same 
problem just a few days ago.  The problem seems to come about because 
ReadWriteStream inherits the "on:"  method from WriteStream, where it 
is:

on: aCollection

	super on: aCollection.
	readLimit := 0.
	writeLimit := aCollection size

This sets readLimit to 0 so that in the "next" method the test  
"position >= readLimit" is true and the method returns nil.  My quick 
and dirty fix for this was to define a new "on:" directly in 
ReadWriteStream class as:

on: aCollection

	super on: aCollection.
	writeLimit  :=  aCollection size.
	readLimit := writeLimit.

I say "quick and dirty".  Perhaps there is a standard methodology for 
checking if changing a pre-defined method causes unwanted interactions 
within the system, but I haven't gotten to that part yet in my study of 
Smalltalk.  In any case this does make the examples on p. 174 - 175 
work as printed (almost as printed -- there may be a non-parallelism 
issue with "nextPut:").

I'm using Squeak 3.4.  I looked back as far as Squeak 2.8, where this 
situation is still wrong.  "Squeak, A Quick Trip to Objectland" is a 
new edition of a book called "A Quick Trip to Objectland", which was 
written in a dialect of Smalltalk other than Squeak.  It makes one 
suspect that the examples were checked in that other dialect and taken 
over to the Squeak book without all getting checked in Squeak.

   -- Bert



More information about the Squeak-dev mailing list