Confused about FileReference read/write streams

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

Confused about FileReference read/write streams

Sven Van Caekenberghe-2
Hi,

Since ever (or as far as I can remember), FileReference made a distinction between read and write streams, see #readStream[Do:] and #writeStream[Do:] - these return a ZnCharacterReadStream and ZnCharacterWriteStream in Pharo 7.

Along the same lines, #binaryReadStream and #binaryWriteStream where introduced. However, the first returns a ZnBufferedReadStream (OK) while the latter returns a ZnBufferedReadWriteStream. Why ?

I think it would be generally better if a standard ZnBufferedWriteStream where returned.

ZnBufferedReadWriteStream is not a very pretty class to say the least, it also strikes me as confusing.

What would break if we changed this ?

If necessary there could be something like #readWriteStream[Do:] I guess.

Sven


Reply | Threaded
Open this post in threaded view
|

Re: Confused about FileReference read/write streams

Guillermo Polito
Hi Sven,

On Mon, Sep 17, 2018 at 4:14 PM Sven Van Caekenberghe <[hidden email]> wrote:
Hi,

Since ever (or as far as I can remember), FileReference made a distinction between read and write streams, see #readStream[Do:] and #writeStream[Do:] - these return a ZnCharacterReadStream and ZnCharacterWriteStream in Pharo 7.

I think so too.
 

Along the same lines, #binaryReadStream and #binaryWriteStream where introduced.

Well, when I did the stream changes on FileSystem, there was already support for binary streams. I just exposed it in the API :)
 
However, the first returns a ZnBufferedReadStream (OK) while the latter returns a ZnBufferedReadWriteStream. Why ?

I cannot tell now the details, but there were some parts of the system where it was assumed that a write-stream is read-write.
IIRC this was related with the changes/sources file handling.
 

I think it would be generally better if a standard ZnBufferedWriteStream where returned.

ZnBufferedReadWriteStream is not a very pretty class to say the least, it also strikes me as confusing.

What would break if we changed this ?

If necessary there could be something like #readWriteStream[Do:] I guess.

That could be a cleaner way to do this, yes.
And this would isolate strange uses.
 

Sven




--

   

Guille Polito

Research Engineer

Centre de Recherche en Informatique, Signal et Automatique de Lille

CRIStAL - UMR 9189

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


Web: http://guillep.github.io

Phone: +33 06 52 70 66 13

Reply | Threaded
Open this post in threaded view
|

Re: Confused about FileReference read/write streams

Guillermo Polito

On Tue, Sep 18, 2018 at 10:14 AM Guillermo Polito <[hidden email]> wrote:
Hi Sven,

On Mon, Sep 17, 2018 at 4:14 PM Sven Van Caekenberghe <[hidden email]> wrote:
Hi,

Since ever (or as far as I can remember), FileReference made a distinction between read and write streams, see #readStream[Do:] and #writeStream[Do:] - these return a ZnCharacterReadStream and ZnCharacterWriteStream in Pharo 7.

I think so too.
 

Along the same lines, #binaryReadStream and #binaryWriteStream where introduced.

Well, when I did the stream changes on FileSystem, there was already support for binary streams. I just exposed it in the API :)
 
However, the first returns a ZnBufferedReadStream (OK) while the latter returns a ZnBufferedReadWriteStream. Why ?

I cannot tell now the details, but there were some parts of the system where it was assumed that a write-stream is read-write.
IIRC this was related with the changes/sources file handling.
 

I think it would be generally better if a standard ZnBufferedWriteStream where returned.

ZnBufferedReadWriteStream is not a very pretty class to say the least, it also strikes me as confusing.

What would break if we changed this ?

If necessary there could be something like #readWriteStream[Do:] I guess.

That could be a cleaner way to do this, yes.
And this would isolate strange uses.
 

Sven




--

   

Guille Polito

Research Engineer

Centre de Recherche en Informatique, Signal et Automatique de Lille

CRIStAL - UMR 9189

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


Web: http://guillep.github.io

Phone: +33 06 52 70 66 13



--

   

Guille Polito

Research Engineer

Centre de Recherche en Informatique, Signal et Automatique de Lille

CRIStAL - UMR 9189

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


Web: http://guillep.github.io

Phone: +33 06 52 70 66 13