[BUG] ReadStream>>isEmpty ?
ken at kencausey.com
Fri Aug 8 21:34:33 UTC 2003
On Fri, 2003-08-08 at 16:19, Andreas Raab wrote:
> > That simple of a solution won't work either.
> It absolutely will.
> > ReadStream>>size simply returns readLimit which can be
> > non-zero and still mean there is that can be read from
> > the stream.
> A stream isn't "empty" just because you can't read from it. That's called
> "at end". The implementation of #isEmpty by using size is therefore
> completely well-defined. It asks the stream if there are any elements
> whatsoever and if there are, it will answer true. What the current position
> of the stream is, is entirely irrelevant in this context.
(ReadStream on: #(1 2 3 4 5) from: 3 to: 3) size
I have to disagree that size is properly implemented.
> Note that this interpretation is also consistent with the collection
> protocol. In fact, one can rightfully claim that "streams" are nothing but
> collections with a "cursor" which indicates what element to answer when you
> ask for the #next element and very few other methods. This has always been
> my favourite interpretation and I find it most unfortunate that streams
> don't support the collection protocols as it would mean that the concept of
> streams can be fully explained by saying "a stream is a collection with a
> cursor" which would remove much of the need for learning their
I understand that now, but I have to blame a large part of my
misunderstanding on the fact that both the ReadStream and WriteStream
class method on:to:from: comments use the word "copy".
> In fact I think that you wouldn't even have that confusion about the
> "meaning of size" if you would have been introduced to streams that way
> (which isn't your fault).
My confusion is based on the code in the image which clearly doesn't
match any idea of size that I can come up with.
> - Andreas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20030808/107782cd/attachment.pgp
More information about the Squeak-dev