writing to a stream after close

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

writing to a stream after close

Mark Volkmann
Why is it that when I do a "print it" on all the code below, it  
outputs 'foobar'?
Shouldn't the writing of 'bar' fail because I've closed the stream?

ws := WriteStream on: ''.
ws nextPutAll: 'foo'.
ws close.
ws nextPutAll: 'bar'.
ws contents

---
Mark Volkmann




_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: writing to a stream after close

Nicolas Cellier-3
Mark Volkmann a écrit :

> Why is it that when I do a "print it" on all the code below, it outputs
> 'foobar'?
> Shouldn't the writing of 'bar' fail because I've closed the stream?
>
> ws := WriteStream on: ''.
> ws nextPutAll: 'foo'.
> ws close.
> ws nextPutAll: 'bar'.
> ws contents
>
> ---
> Mark Volkmann

Close does nothing. Browse implementation.
It is only here so that you can replace a file stream or socket or pipe
etc, with an internal stream transparently...
... Well, almost transparently: you should not expect the latter to
simulate any OS error like read only, lost connection, broken pipe, or
closed file.

Nicolas

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners