[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: state of the Lua nation on resource cleanup
- From: Mark Hamburg <mark@...>
- Date: Sun, 25 Jan 2009 22:58:18 -0800
And I should perhaps have mentioned the more general patterns:
io.with_openfile_do( filepath, function( file )
-- do stuff
end )
And
io.with_newfile_do( filepath, function( file )
-- do stuff
end )
The former opens the file if it already exists and hands it to the
function for processing. The latter creates the file and hands it to
the function for processing. If the function fails, it deletes the file.
So, a couple of questions to ask are:
* How expensive is it to generate the closures that this sort of style
promotes?
* Are the cases where we need to do this sufficiently rare that they
are simply the job of the library writer or are they going to be
common enough and ad hoc enough that library writers are unlikely to
cover them all?
Mark