DanI at wdi.disney.com
Fri Jul 10 14:47:18 UTC 1998
Bob (and all)
>!PositionableStream methodsFor: 'testing'!
> "Answer whether the receiver's contents has no elements."
> ^position = 0! !
>Wouldn't it be better as
> ^readLimit = 0
In my opinion, this is one of many places in Squeak that needs to get cleaned up rather than fixed. #isEmpty is a message normally defined for collections (to go with size, at: , etc) and, at least now, streams are different from collections (built around atEnd, next, etc).
It isn't clear from the message name what is should mean for a stream since, for writing, it would probably mean 'has not been written into', or 'atBeginning', whereas for reading it would probably be 'usedUp', or 'atEnd'. We could try "fixing" it as you suggest (the best fix would be a good comment) but I would first ask, where is this being used, and use stream protocol instead (probably involving a rename to #atBeginning).
The question of where #isEmpty is sent to streams, of course, is a very difficult question to answer right now, since there are MANY senders of #isEmpty, of which probably only a couple (or hopefully none) are streams.
Yet another reason to get type inference working in Squeak.
More information about the Squeak-dev