String findTokens:?

Bijan Parsia bparsia at email.unc.edu
Tue Apr 22 21:40:58 UTC 2003


On Tue, 22 Apr 2003, Joshua 'Schwa' Gargus wrote:

> Hi Jimmie,
>
> On Tue, Apr 22, 2003 at 03:08:08PM -0500, Jimmie Houchin wrote:
[snip]
> > file _ FileList2 modalFileSelector.
> > fc _ file contentsOfEntireFile.
> > file close.
[snip]
> > 1. I am creating a variable for the file contents and then discarding
> > (closing) the file. Is that good form? Or would it be just as
> > appropriate to assign the file contents into the file variable?
>
> You're doing the right thing.  Otherwise how would the file get closed?
[snip]

Actually, unlike earlier versions of Squeak (2.2? 2.3?), currently there
is finalization and so GC files will be closed. You're still doing the
right thing, however :)

A righter thing would be (something like):
	[fc _ file contentsOfEntireFile] ensure: [file close].

It probably doens't matter for this example, but if you had more complex
processing of the file, this is very handy (and a good idiom).

Cheers,
Bijan Parsia.



More information about the Squeak-dev mailing list