Possible bug with Streams and upToEnd

tim Rowledge tim at sumeru.stanford.edu
Mon Jul 12 17:31:30 UTC 2004


Russell Penney wrote:

> I was playing with streams and noticed something a bit weird.
> 
>  
> 
> | s |
> 
> s := ReadStream on: ( ByteArray new: 10 withAll: 32 ).
> 
> s upToEnd
> 
> ->  a ByteArray(32 32 32 32 32 32 32 32 32 32)
> 
>  
> 
> | s |
> 
> s := ReadWriteStream on: ( ByteArray new: 10 withAll: 32 ).
> 
> s upToEnd
> 
> -> a ByteArray()
> 
>  
> 
> Is that right? Should they both return the same collection? Seems very 
> counter-intuitive to me as it is now, but I might be missing something.
This is an astonishingly common 'problem' - searching various ST related 
archives would probalby find hundreds of unique threads on it.

Basically, since you didn't write anything to the ReadWriteStream you 
get back that nothing when you ask for what was written. I know, it's 
not all that logical seeming but that's what happens. Been that way for 
a long time and changing it would probably mess up the electron 
mass/charge ratio or something.

tim




More information about the Squeak-dev mailing list