In fact the question comes from the fact that they are not polymorphic and
you should know if you're manipulating a closable stream or not...

Maybe a solution is indeed to use #writeStreamDo:, that should behave well
even for in-memory, collection streams, no?

On Thu, Jun 29, 2017 at 4:58 PM, Sven Van Caekenberghe <s...@stfx.eu> wrote:

>
> > On 29 Jun 2017, at 16:07, Jérémie Regnault <jeremie.regna...@outlook.com>
> wrote:
> >
> > Hi,
> >
> > I am writing tests with streams, and I noticed that a stream opened on a
> > string doesn't close, but FileStreams do close. Is it normal ?
>
> How do you mean that ? That FileStreams close automatically ?
>
> That is indeed the case, that they are closed as a finalization action
> (i.e. when they become garbage), but that I consider that a fail safe
> thing, not something you should rely on. They should be properly closed,
> like #readStreamDo: and #writeStreamDo: do.
>
> Streams over collections such as Strings do not need closing, as there is
> no opening either. But general stream code better does.
>
> > --
> > Jérémie Regnault
> >
>
>
>


-- 



Guille Polito


Research Engineer

French National Center for Scientific Research - *http://www.cnrs.fr*
<http://www.cnrs.fr>



*Web:* *http://guillep.github.io* <http://guillep.github.io>

*Phone: *+33 06 52 70 66 13

Reply via email to