String findTokens:?
Jimmie Houchin
jhouchin at texoma.net
Tue Apr 22 21:50:41 UTC 2003
Bijan Parsia wrote:
> 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.
Hi Bijan.
Thanks for that information. Anything that leads Squeakers to write more
robust (Erlang hasn't TMed it yet. :) code is a good thing.
I'll take a look at the #ensure: method code and learn and begin to use.
Jimmie Houchin
More information about the Squeak-dev
mailing list
|