[Cuis-dev] FileMan and FileStream?

KenD Ken.Dickey at Whidbey.com
Fri Dec 18 21:18:36 CST 2015

On Fri, 18 Dec 2015 22:06:07 -0500
"Phil (list)" <pbpublist at gmail.com> wrote:

> I could do something like that which will of course end up resulting in
> my creating helper methods that look suspiciously, exactly, like
> private*Stream.  The main argument I'm making is that accessing files
> via streams (which get passed around *a lot*... typically only a bit of
> top level code even knows or cares if it is a file) is a pretty common
> use case so why not just acknowledge it and make them public in name
> and usage?

FileMan is using what I would call a functional style which ensures that a stream is closed.
writeStream: blockWithArg 
    "If the file already exists raise FileExistsException.
     Creates the directory if it doesn't exist."
    | stream |
    stream := self privateWriteStream.
    [ blockWithArg value: stream ]
	ensure: [ stream ifNotNil: [ :s | s close ]]

Passing in a block which takes a stream argument is a natural style.

Forgetting to close a stream is also, IMHO, natural.

Don't use private* and you don't have the problem to worry about.

It has been designed out.

I think we should remove the bulk of the private*Stream uses. 


More information about the Cuis-dev mailing list