Should ReadStream>>next signal EndOfStream?
Bob Arning
arning at charm.net
Thu May 18 02:26:42 UTC 2000
Helge,
On Thu, 18 May 2000 03:35:46 +0200 Helge Horch <Helge.Horch at munich.netsurf.de> wrote:
>Helge, meet Embarassment.
Don't be embarassed - I've just run across some of those methods before.
>Sorry if I broke eekMail...
I'm still running that on 2.5 so no danger there.
>Unless other embarassing flaws remain, I shall release the port tomorrow
>(well, actually today, but after a good night's (whatever remains of it)
>sleep).
As a slight modification, I would suggest
next
"Primitive. Answer the next object in the Stream represented by the
receiver. Fail if the collection of this stream is not an Array or a String.
Fail if the stream is positioned at its end, or if the position is out of
bounds in the collection. Optional. See Object documentation
whatIsAPrimitive."
<primitive: 65>
position >= readLimit
ifTrue: [^EndOfStream signal]
ifFalse: [^collection at: (position _ position + 1)]
This change allows the exception to be caught and a different value returned. Compare the results of:
| s |
s _ ReadStream on: Array new.
([s next]
on: EndOfStream
do: [ :ex | ex resume: 'that''s all there is']) inspect.
with both versions of #next to see the difference.
Cheers,
Bob
More information about the Squeak-dev
mailing list
|