jhouchin at texoma.net
Tue Apr 22 21:50:41 UTC 2003
Bijan Parsia wrote:
> On Tue, 22 Apr 2003, Joshua 'Schwa' Gargus wrote:
>>On Tue, Apr 22, 2003 at 03:08:08PM -0500, Jimmie Houchin wrote:
>>>file _ FileList2 modalFileSelector.
>>>fc _ file contentsOfEntireFile.
>>>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?
> 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).
> Bijan Parsia.
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.
More information about the Squeak-dev